Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp735604pxu; Mon, 23 Nov 2020 02:49:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJztMQdjG+Aebug47ZMNy4nuLfamtYaB00qt8n9sN2Scu67z/DP+ThnM208RzFbs7En3lPCC X-Received: by 2002:aa7:dccd:: with SMTP id w13mr9786871edu.385.1606128576228; Mon, 23 Nov 2020 02:49:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606128576; cv=none; d=google.com; s=arc-20160816; b=mXOSQhRMw98zEgHZW4EXUb91uzh4mnUNhPAPL1Z6leEJCFbYWhr7cYVTp8jlL4cL9v 8iWQVe+c7I0exXc4KS1ohB54vp/b4ZKKouyPneaMmzWFZNw83xiCbeo3dn1du9p7odei Jv91TFDCrSOtUWwGF8PvB80NAo924BU6+nSR/5CgvR+QzLc7gOx5m3e1XkkskrRxtVbY CuqJiLwwJYmmiKsYWN6TbUAkLbYUJNSqU4OTIe+Isd6GWBrVA/2JuIXnJHCBLInYykR1 n+AJVzKBs05PEyQG+h9nH1YwVjM4c99qi0r5eNj4FtBfMj4eAxy/uaurG9qFoK4hvhZ4 dBwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=7J/b1u7jGHBsUtbtVutnZDvh/ftlE5FAscTtFEJPZJQ=; b=YGvFclqaMg7ey43bepmRNDZ6wFfxhRnj26nwJ7tj4HwV0VZB6x5H/7T443gTNovuJu imWTAtrCODoOnAA1/Tr4jPRFU3yAleIX5UfW1Hc1k+B+G0WpIQA218BhLCJ+1DBahdZz beWv58YA09+s5uYWmW+MdAxqfz/9ZwAulV9l0iVQundv/fSVMgtg2b13CZKLlWcMbpgO Akxu04XNMsuOCgc3b4rmlIayBxUwTw3hUgx//4M/zqAJ38R95Gx+0jtGlPkL9W5enACd A9UVtSaXizBM2INER7KekGrpAjEYxb3n+VL+PRVYlxZaZrxAq5vLlCTjqVgLDlvX3jUW m8qQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e18si6207922ejq.261.2020.11.23.02.49.13; Mon, 23 Nov 2020 02:49: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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728721AbgKWKrE (ORCPT + 99 others); Mon, 23 Nov 2020 05:47:04 -0500 Received: from foss.arm.com ([217.140.110.172]:41544 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728690AbgKWKrD (ORCPT ); Mon, 23 Nov 2020 05:47:03 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0CE96101E; Mon, 23 Nov 2020 02:47:03 -0800 (PST) Received: from [10.57.53.209] (unknown [10.57.53.209]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 649513F70D; Mon, 23 Nov 2020 02:47:01 -0800 (PST) Subject: Re: [PATCH] coresight: tmc-etr: Check if page is valid before dma_map_page() To: Sai Prakash Ranjan , Mathieu Poirier , 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 References: <20201123102133.18979-1-saiprakash.ranjan@codeaurora.org> From: Suzuki K Poulose Message-ID: Date: Mon, 23 Nov 2020 10:46:56 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20201123102133.18979-1-saiprakash.ranjan@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/23/20 10:21 AM, Sai Prakash Ranjan wrote: > 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 Reviewed-by: Suzuki K Poulose > --- > 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 >