Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3258444rwb; Mon, 15 Aug 2022 22:31:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR7IKyCx8fs0nPlMemcnUu7OPa7XvmYgy5AkIi+Q5G/pkxm+HdwZkLBM3Z+E9OBMmWA6Th0m X-Received: by 2002:a17:902:cccb:b0:172:60b7:4590 with SMTP id z11-20020a170902cccb00b0017260b74590mr12956810ple.152.1660627906181; Mon, 15 Aug 2022 22:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660627906; cv=none; d=google.com; s=arc-20160816; b=yG84gB4hk2Fvw8nlJbXr2oiYJMr8df4ZzpkhXFp5baNrqrcaRx3+/CVMfSSj3BOmiA 59OJYQzJ6R7QttqY0JgC+F/7ql6/X4U5t8FmqacGz2R3/9/+MbmCHtPJWMLvUWL3wdKu ywqq8di5Kq/rfIBi4nNdvCA8iUVZisH32YfD2Znpy0awEF8Vb8AlwjsXOUb26IaAXcjZ Hl1QwDiTupSQtmU3AV5xEwtycLMyVhDof+Lyl5lL2/gi+UNNkKCjxV+Ii/saejDcFaQj NEjurksAGnYpVGOwHijk0IzIX+We4cwB9bKJnYx8lwcGPXQKr3Nq/KuggXx+7COfv1Mg 2FgA== 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=vv5dOouwIDzIrKEmYkM3b6LMDOnh3rJ1vffsaHy5ki56zPyh0Rdau+qdcGiFsxN12o RqdNJiEML3fnMyTHVMTXb9QLMMBi3BpiQgCEXbfHHrf11/iuOENVEMJyZiZhKeNYPlm3 IxmNISqjKEuqCs1WrWPAQ9Gk0/n3U6vSo8YYqboTm5bbeSMrn1Dnkd2MOIBjVyKKlZWH KgX/v1+H2Mw0dpD+vhPpC3Xmj32DpQQpzWPZV8tQ9sT1gmTD+3hsMXAjmrFzYwGhjp71 C442Yic2lfDxDqpkki0zXygvXOc1QJbjNh0reuHzt/+ZHO7rz7U8epCfJGaH+x9in6/E Dvdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rMyf8akS; 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 nu10-20020a17090b1b0a00b001f7299d9c0fsi15167269pjb.59.2022.08.15.22.31.35; Mon, 15 Aug 2022 22:31:46 -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=rMyf8akS; 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 S231642AbiHPEnb (ORCPT + 99 others); Tue, 16 Aug 2022 00:43:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232007AbiHPEkp (ORCPT ); Tue, 16 Aug 2022 00:40:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4640A50DF; Mon, 15 Aug 2022 13:31:56 -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 ams.source.kernel.org (Postfix) with ESMTPS id 8F25BB80EA8; Mon, 15 Aug 2022 20:31:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAC25C433D6; Mon, 15 Aug 2022 20:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595514; bh=Vi5nOn57Hq/yjy93n2CxGZ9yBwsNUVNFG9Sh/CociKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rMyf8akShDbN7TfyTmnyRdZBGDADNsXcyH9tMFTFUUI38c5oENYs5nxm8JSltyB6G cMqtZpHNFGKEx8tfyrjYZzqACHstqEZbGYOsHMv2mFh7Z2Q+CDCVLLKb0qI2WLJyAc JSSaMHGki+ZFMkXQ8FFTaxlx4U1azQYQbRP3NUXw= 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.19 0787/1157] intel_th: msu-sink: Potential dereference of null pointer Date: Mon, 15 Aug 2022 20:02:23 +0200 Message-Id: <20220815180510.969405483@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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