Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5876144pxu; Wed, 23 Dec 2020 07:36:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwt8sNMFYLvISSasfXpLYEtcgpBrktVLoWngx/rbQzPEoxCHC6+JDo3ymWGQyAA9uTDYvUj X-Received: by 2002:a50:bf4a:: with SMTP id g10mr24856364edk.201.1608737798031; Wed, 23 Dec 2020 07:36:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608737798; cv=none; d=google.com; s=arc-20160816; b=ypCjw1vF0EuKGrdVJZcxlFfa8zznIqjgJ6GTag3+2lLQ4grDTC0La7vG6UGxCtcaNS Ry6uTPLVkN8toXyOaLWUZqQyesXFgxQB7ppCNW67+qvBfKVvn8M/Xn7zydhdgRJyeL54 CI4Ge+/RgrV1YNSGMSh1PgAInEA6/u/qvz6wyojMqNn1x2vc6Qa4E61Pk5WtajOwqf9F fc1N74K9unsxa90OuJWb0iwXU7bcVSDd5+zCeP1eYdI5o/wm0HF0odtt1XAfD4sTusYj 9l8jTxrFGHUoNYtJ6XGntqsdBoQSzrcZNk576RDcYGXyTECuEV8yr81CSxrSongVRzTX JWFA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yv0j2j7VUencqFp9Is5AJ9Ibz4hSuRvFZqNjKzEMUoo=; b=JOxZWm6CvOt4TPjt6V3GdINZvOSAmPw0AZY9aMPumGWQI0UhbhKNn2TQjG9dmi/IcH N0Ctji9970GYi6MV7lrE/8gBOM8wOuGZ5ykR704KrNLd2y89nc0ti2olSbgt9wmDZg2f ZOIeL5mxhccIoe9G41/isgiBwZbqzNclzmFtDdjSElntkSO+IAAViJhIkjFMsypU7Grr 6gb/K1wj6uhb+siWGVyqkvnLCTWPXpdx/BH/1620dc2ZUMlQk8vCirht3ubkO3Ro1sK8 YegDwQBgFUZESL6XGt9nxXnjsuoGq9a2De/A+9aeyMqYQ5fw9RMRNb4exN3vJTaeasSI NOog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wLJgBBJh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f15si14276514edc.147.2020.12.23.07.36.15; Wed, 23 Dec 2020 07:36:38 -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=@linuxfoundation.org header.s=korg header.b=wLJgBBJh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728357AbgLWPeE (ORCPT + 99 others); Wed, 23 Dec 2020 10:34:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:44716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbgLWPd7 (ORCPT ); Wed, 23 Dec 2020 10:33:59 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 91C3C2335A; Wed, 23 Dec 2020 15:32:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1608737580; bh=Sa8wnWGI+jrp/L3LiFuUnc4c/d7KE7JE2axxyux/NqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wLJgBBJh0SMp/P09G15QW4WuFQYhlNCQAxmUpPWso3/xkJw+JRAVrxqi+bEKnFOjo o4vMAmT+G0NC4mHq6jQfz0JZbKhk0wzWv49lLRipAhfu/WhvVca4NyMKbZ7J7ExreY OeftDMOYxa2TMSNLqMoiIeB7yB33WymoWzPeK6G4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Suzuki K Poulose , Mao Jinlong , Sai Prakash Ranjan , Mathieu Poirier Subject: [PATCH 5.10 16/40] coresight: tmc-etr: Check if page is valid before dma_map_page() Date: Wed, 23 Dec 2020 16:33:17 +0100 Message-Id: <20201223150516.338413247@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223150515.553836647@linuxfoundation.org> References: <20201223150515.553836647@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mao Jinlong commit 1cc573d5754e92372a7e30e35468644f8811e1a4 upstream. 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 Reviewed-by: Suzuki K Poulose Signed-off-by: Mao Jinlong Signed-off-by: Sai Prakash Ranjan Signed-off-by: Mathieu Poirier Link: https://lore.kernel.org/r/20201127175256.1092685-13-mathieu.poirier@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 ++ 1 file changed, 2 insertions(+) --- 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_pa } 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))