Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2838019rwb; Mon, 15 Aug 2022 12:19:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR6S1H5jRprXIZyG3DaZO9HT6Wb0HIzyvMwwLHP6LDCoFBk3epiKdEinHZ71ztA3tBvhOuNp X-Received: by 2002:a17:907:6d12:b0:731:8595:9784 with SMTP id sa18-20020a1709076d1200b0073185959784mr11200913ejc.323.1660591194241; Mon, 15 Aug 2022 12:19:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660591194; cv=none; d=google.com; s=arc-20160816; b=RKOf5mJBBd5FdWvbECLpZT9bEZBxfM00IXPifmFSp51vR8P35+//wUP3zxZUKYM87F XHt3fx98bXX0O+k32wRCDvjCRt3ysH+arsNl4kx7LztkuCDL4iNLe/p4YZgPEj8JBhVb 1iP2gl33Z3MSzvhowATUvlnaGkBJqMceZum2VLxL8gUh1o4PekEmP46qkd0+8kMtyMWX 1OZXJFpAynZawjh0P6D/ov/smlwjAn/5HW/v1q6nYS6mvBTx06I+648TTsqzgVwOSZqh N/smCbwyG/+fFtdDRX04LjjexYLe/7tmkTLlz4yA/huh69I0leAWP6iJHy53ZXvKf07f kI6Q== 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=RaixFD14vkGhLxYcHfyXii1BE4oDG0uzPOO0srkXOtHvfwMOmXXPN9crF1X2BDEa/v 6d1GOJIljZTzFN1e6yhnv50RnvGtpiBajdvFG7CyQY21jJzm/g0tMbwElKvNgsQj25+I cyGHtbvokxQEeJ5hL0/EWjhNZGejDxQZpmoZghTkTItaujWLUTkS3hmiM/C6wxkiSE2S vu8s7u1ePGxqlCbP3u8QJTf9kE3F6kP8VaIdYQ7Wc50ORucUg2pdPQdVUDeNfyprHOEX 5Lls3YNxwKz6gqUimcamDvcLGQW9DaRfh8T2Qr13QqS0RL3y1ai4mHYiglxN9MIN99sy n8MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EuNWWr5B; 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 k9-20020a170906128900b007318588b4bbsi7212768ejb.54.2022.08.15.12.19.25; Mon, 15 Aug 2022 12:19:54 -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=EuNWWr5B; 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 S1344117AbiHOTPt (ORCPT + 99 others); Mon, 15 Aug 2022 15:15:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343790AbiHOTNA (ORCPT ); Mon, 15 Aug 2022 15:13:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C9E651429; Mon, 15 Aug 2022 11:37:32 -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 3C54F6113D; Mon, 15 Aug 2022 18:37:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4224DC433D7; Mon, 15 Aug 2022 18:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588650; bh=Vi5nOn57Hq/yjy93n2CxGZ9yBwsNUVNFG9Sh/CociKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EuNWWr5BoPdv9NymjfIOHdAs+hnZ4rZwQoF8Lh1bfBKOxw98gJYqKVA/zjAJTO0ul tD0XQd/2SAFhC0NnmipAjL0joFrzfqclxU/oyJWAaJYs30gxe84rRI1TN2zVjbOYbu 6MqG/wCC6AShyXlPSyK8TQzNH+6otCOzAuHdJ6I0= 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.15 472/779] intel_th: msu-sink: Potential dereference of null pointer Date: Mon, 15 Aug 2022 20:01:56 +0200 Message-Id: <20220815180357.464305629@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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