Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2966272rwb; Mon, 15 Aug 2022 15:04:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR4LNhPYZXaGiYHxORBL0PaMaBeOxQqt5yScAvDBnddP8mNxtlu0ZjFSmFVogyOLNC22K0yz X-Received: by 2002:a17:906:58d1:b0:738:5087:9ac6 with SMTP id e17-20020a17090658d100b0073850879ac6mr4383059ejs.422.1660601063814; Mon, 15 Aug 2022 15:04:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660601063; cv=none; d=google.com; s=arc-20160816; b=AOe8esRwlMKhfRYtpmELunGIS1J/5K7u0UmV/1GtNHKoG1DF9LQbhPH/D3+gNFjeaG 7LmW4m3xH+2CPylZp/1NzmZ1WH4g8OVi6ezIm+4Cf1Pu9cL71BmnuanjVQ8SkhCxNLv0 prF6ZfkjQew7/LlRBQ6fqVKTwS6kxQwT2Cyuhw1byJGj4izSVFacryaR06hdzZvWd4DG b2FOOo+BjFcHN6qTLiXNW8S6tpoxB9CUZjpNLz7t3L2+Ki66Z9atyp320cKgr1VB7M50 eRZpz/VnlcjZ8hV5X9qZH5HpCtFq9/pOY5p5NHEBP1odlyR5eV8lLP0HmC2Md8xOg9iC /CMg== 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=ig57phJXUR525/UcgPnW0w8DO+gseIe4OAjjmHNj2Rk=; b=B6/rxD2ofwDSHDbuIgHvuQc1NjOlQvAcThds+CNDmdzjVysJ0TaM9HItLZpZ8ph4Fo Ld84a7oj9aiQkkxPHdXVlCfH79VvlZChxM9wzTFrzCdJFMO6e9sjyP/JTgnJObdDQ5Yh ZuoPYIua9bWscvTB+iDzS15tRU6wk9vJWDmsv3NoAdNp4Q2bkxOAh51qLNdg6c+d+Ckt iqJaOWc/TiCwVq+Far/VmfmD9R0+dFzb2+fPaxax/c0f3n2Anek25X+I+QXzJi0E6eK6 GckijBAS8qNDifn1Q+tp+BPfkmmHUFPTVEaRJUAA+g89K195+vze+/ucjukOLewtmds4 5O2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iLq1uWUI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jx2-20020a170907760200b00726e142a88esi6700006ejc.983.2022.08.15.15.03.55; Mon, 15 Aug 2022 15:04:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iLq1uWUI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1343642AbiHOWCl (ORCPT + 99 others); Mon, 15 Aug 2022 18:02:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344310AbiHOWA3 (ORCPT ); Mon, 15 Aug 2022 18:00:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D8FB11A1F; Mon, 15 Aug 2022 12:35:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E0F666111E; Mon, 15 Aug 2022 19:35:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2F0FC433D6; Mon, 15 Aug 2022 19:35:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592106; bh=Vi5nOn57Hq/yjy93n2CxGZ9yBwsNUVNFG9Sh/CociKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iLq1uWUIJnFcFZJjvfjoTVI0FFtK+JCCAee3qIoFfzoxx2aq/6PimIabqRoYMHXHN wyKKruGdH2/JIqBZjY9mOeebIH8akeivbCqemWLjv0pfky7JPVf1nMvM65fMwh0w3X sQpZ+JQsH2LVL1NP7jaZ5k3iiorOJZZ1MBlpWbxo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , Jiasheng Jiang , Alexander Shishkin , Sasha Levin Subject: [PATCH 5.18 0735/1095] intel_th: msu-sink: Potential dereference of null pointer Date: Mon, 15 Aug 2022 20:02:14 +0200 Message-Id: <20220815180459.792701868@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiasheng Jiang [ Upstream commit 82f76a4a720791d889de775b5f7541d601efc8bd ] The return value of dma_alloc_coherent() needs to be checked. To avoid use of null pointer in sg_set_buf() in case of the failure of alloc. Fixes: f220df66f676 ("intel_th: msu-sink: An example msu buffer "sink"") Reviewed-by: Andy Shevchenko Signed-off-by: Jiasheng Jiang Signed-off-by: Alexander Shishkin Link: https://lore.kernel.org/r/20220705082637.59979-3-alexander.shishkin@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/hwtracing/intel_th/msu-sink.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hwtracing/intel_th/msu-sink.c b/drivers/hwtracing/intel_th/msu-sink.c index 2c7f5116be12..891b28ea25fe 100644 --- a/drivers/hwtracing/intel_th/msu-sink.c +++ b/drivers/hwtracing/intel_th/msu-sink.c @@ -71,6 +71,9 @@ static int msu_sink_alloc_window(void *data, struct sg_table **sgt, size_t size) block = dma_alloc_coherent(priv->dev->parent->parent, PAGE_SIZE, &sg_dma_address(sg_ptr), GFP_KERNEL); + if (!block) + return -ENOMEM; + sg_set_buf(sg_ptr, block, PAGE_SIZE); } -- 2.35.1