Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp722808pxu; Mon, 23 Nov 2020 02:23:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7BhFsZHH1DYdkzPajqQ3hmeQaNcjIi5YpAPIk3nZJMwGutTtMydj4iL+A948Q5RVo0tUR X-Received: by 2002:a17:906:8415:: with SMTP id n21mr12130354ejx.399.1606127016181; Mon, 23 Nov 2020 02:23:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606127016; cv=none; d=google.com; s=arc-20160816; b=IUS/y3x5nVyTn6wH6MjUfjYuvK1JM7SkO4JPQxthscAw3iNByRn/FeD4mVZQCfjIXz zJg/nq6GavMw/x8cqQzeHQWZi9PgVtjI4R8RZB7C63dGnDsu2ME+pTG6r3ZbZB8dbLRZ FMTFA8Eyt0xuiMDbF1IppNdoxFUeuGTCKqjpoT13Th7PHw2VGFtK31GZjwIfwvAiCmG0 ZcSw2XXkddMGzleFz94KAKZlJCh/5+t9Z3U1Rmh3DvrHkI/G6p93h144o3Qitgv/xk8y +84lieG6QW1ia1sskQVgetueVTKptd0UgkBqDs3Hxg7+QqK0Cson9+0Kr0nvvAjYrMMd uiWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dmarc-filter:sender :dkim-signature; bh=ANmJoYuuswtZF1g4TGnjWKvS5jfl6v0C3i9XCSjNnmQ=; b=B3nj+xiBDgViO+gmzmzDBKNUcBIQyJNN7juw9fwslEUTLudhJcFSUyyu6r1ShlxI4U A5X6bmNjAj9FhcD/6WwsK8UYPDZRQRqX7K08y+VIwQPobk9ndvrSibMgqxXDtWeroyXM YURYoeWiTsa3HAj1yXgq8WtkCBTe1RiSpiqGyoB8W30Fp46DadeoONdmLgG4fRQ/k/kz ONXpxHru3xHCpS8ycAnQbJHFfqPm1BGvWukljuRg99JpxUS3zfE3DpIMIv6Jhw7mez8g dE+3g7lNHPFVsDxscUs+5DMUYtTqDQo29Gh87BByTJ1JrHsTcnmszpwHz1c4AfWXVoFy 4AuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=RxTJdyrG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i12si6490188edj.263.2020.11.23.02.23.12; Mon, 23 Nov 2020 02:23:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=RxTJdyrG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728151AbgKWKVr (ORCPT + 99 others); Mon, 23 Nov 2020 05:21:47 -0500 Received: from z5.mailgun.us ([104.130.96.5]:43081 "EHLO z5.mailgun.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727724AbgKWKVr (ORCPT ); Mon, 23 Nov 2020 05:21:47 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1606126906; h=Content-Transfer-Encoding: MIME-Version: Message-Id: Date: Subject: Cc: To: From: Sender; bh=ANmJoYuuswtZF1g4TGnjWKvS5jfl6v0C3i9XCSjNnmQ=; b=RxTJdyrGndI63zgtoBzzYMrBrk5tXSMYNJZ1twRP/jmGMk2X1faGe18g16HuJ4fK/71IfOFL EUnHvndmioBftyuIVfgDzEhU9m3T7B3w06P4Btz/vVT/ofPwGS0kx/1bkbY+916gQRwCNfOr vgFC16LS1AJRLmeYMVF0UXo5PMU= X-Mailgun-Sending-Ip: 104.130.96.5 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n04.prod.us-west-2.postgun.com with SMTP id 5fbb8d380c9500dc7bad62bd (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 23 Nov 2020 10:21:44 GMT Sender: saiprakash.ranjan=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 3A547C43463; Mon, 23 Nov 2020 10:21:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from blr-ubuntu-253.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: saiprakash.ranjan) by smtp.codeaurora.org (Postfix) with ESMTPSA id 20405C433C6; Mon, 23 Nov 2020 10:21:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 20405C433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=saiprakash.ranjan@codeaurora.org From: Sai Prakash Ranjan To: Mathieu Poirier , Suzuki K Poulose , Mike Leach Cc: coresight@lists.linaro.org, Stephen Boyd , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mao Jinlong , stable@vger.kernel.org, Sai Prakash Ranjan Subject: [PATCH] coresight: tmc-etr: Check if page is valid before dma_map_page() Date: Mon, 23 Nov 2020 15:51:33 +0530 Message-Id: <20201123102133.18979-1-saiprakash.ranjan@codeaurora.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mao Jinlong alloc_pages_node() return should be checked before calling dma_map_page() to make sure that valid page is mapped or else it can lead to aborts as below: Unable to handle kernel paging request at virtual address ffffffc008000000 Mem abort info: ... pc : __dma_inv_area+0x40/0x58 lr : dma_direct_map_page+0xd8/0x1c8 Call trace: __dma_inv_area tmc_pages_alloc tmc_alloc_data_pages tmc_alloc_sg_table tmc_init_etr_sg_table tmc_alloc_etr_buf tmc_enable_etr_sink_sysfs tmc_enable_etr_sink coresight_enable_path coresight_enable enable_source_store dev_attr_store sysfs_kf_write Fixes: 99443ea19e8b ("coresight: Add generic TMC sg table framework") Cc: stable@vger.kernel.org Signed-off-by: Mao Jinlong Signed-off-by: Sai Prakash Ranjan --- drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index 525f0ecc129c..a31a4d7ae25e 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -217,6 +217,8 @@ static int tmc_pages_alloc(struct tmc_pages *tmc_pages, } else { page = alloc_pages_node(node, GFP_KERNEL | __GFP_ZERO, 0); + if (!page) + goto err; } paddr = dma_map_page(real_dev, page, 0, PAGE_SIZE, dir); if (dma_mapping_error(real_dev, paddr)) base-commit: c04e5d7bbf6f92a346d6b36770705e7f034df42d -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation