Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2199510iof; Tue, 7 Jun 2022 23:00:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6xFVCsYRZXpTx1rhAhoH1U32caI5ncbVAfylSZA+4iTok5k//se5zA3f8+NSJv7+gI0xj X-Received: by 2002:a17:90a:5d04:b0:1e0:83d7:413c with SMTP id s4-20020a17090a5d0400b001e083d7413cmr36426277pji.201.1654668037994; Tue, 07 Jun 2022 23:00:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668037; cv=none; d=google.com; s=arc-20160816; b=zXacdsd3YlZAQQf+dhpHL+MRHQ+BtQqbexe1dKnIclDVN/aS2lMTPmO5i7OcTy7qPD IWw0f0FLLXGc7Kt/53XngvK7xsVnwOI2cEIq17fMBJcHGWQFt7E61qn9g5Jvsvfd0wZT NoN6/01mJNZsxA19LO480X5WBGSqecdyIFUZZLiz01fLr5OItqeFdjXzH5/Z/PCemZw3 U5FVzFBgkwqikuqVasCcLmqV7S8Zrssy2nCPYk63O+wm51Y1wmqfO2NFIen0AJ7AwFNb 7kaz3YVsj+JVNrcFXUUsYds2de1X6a8wAh9gmdSMPT9coS/XTy93+1Fv77c9MnicOoXM jeWQ== 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=+5s3d5YVeZFYeknkqXNPMQXYB+kIfL+WvueY6aoNWvU=; b=U7uehdVHjYUCmd9SG93/bTu+GiTp4u3av98w8p62QbBFDp9Wq9vZutk0vMV08dLWa/ jKjuUNQGNjXWmA4EGPPvMZCbKz4aCXmhyUwl6DtwE0JD+zMBVVtgnf9C7Yg+ygQD/NJ/ VznWJI0FZUZbdC78fgs1ds8GtGC2MW2zVB2Qxz1okhWeh8+m8CVQdaVXcpIFC8fgyu8N EuTAZI3XIkmuAoVDdWar0c9MDWOkel5tCvQmfKlVybGjyCLaXLkOn4IO9xyWAXr9QLx1 /kgrIc4403ByadqoViHTrpH0qR4J6x0fEusHXbuzHo9vVnjKRupG1S2cNktw/rhCMnvE 7oww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s6LAoqZy; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k15-20020a170902ce0f00b00163ef8dee02si27197180plg.391.2022.06.07.23.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:00:37 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s6LAoqZy; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C75104706EF; Tue, 7 Jun 2022 22:25:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1392441AbiFHAw3 (ORCPT + 99 others); Tue, 7 Jun 2022 20:52:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381444AbiFGVsM (ORCPT ); Tue, 7 Jun 2022 17:48:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAF40239099; Tue, 7 Jun 2022 12:08:12 -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 66965617DA; Tue, 7 Jun 2022 19:08:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 777DAC385A2; Tue, 7 Jun 2022 19:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628890; bh=7gLmPXzMhNy7D2VimkqVQcs4oFEM8KSRbDToOpCrFlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s6LAoqZy4UdzmE6fa9NbIkk/cQ1oBrhk2023b8W6wn44m/JhzGOCoVMi8bnwIQv2M SncGcolC8XnX68/t1qRKCp1LuJm1lznpXO5cLccFPhPSceaYC122ZJdHdDIWsu1qPu Zi/JFMMbjd/KNL5gOKSizLCAbGyXyrAf8FweiuGE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheng Yongjun , Daniel Lezcano , Sasha Levin Subject: [PATCH 5.18 492/879] thermal/drivers/broadcom: Fix potential NULL dereference in sr_thermal_probe Date: Tue, 7 Jun 2022 19:00:10 +0200 Message-Id: <20220607165017.152295215@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Zheng Yongjun [ Upstream commit e20d136ec7d6f309989c447638365840d3424c8e ] platform_get_resource() may return NULL, add proper check to avoid potential NULL dereferencing. Fixes: 250e211057c72 ("thermal: broadcom: Add Stingray thermal driver") Signed-off-by: Zheng Yongjun Link: https://lore.kernel.org/r/20220425092929.90412-1-zhengyongjun3@huawei.com Signed-off-by: Daniel Lezcano Signed-off-by: Sasha Levin --- drivers/thermal/broadcom/sr-thermal.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/thermal/broadcom/sr-thermal.c b/drivers/thermal/broadcom/sr-thermal.c index 475ce2900771..85ab9edd580c 100644 --- a/drivers/thermal/broadcom/sr-thermal.c +++ b/drivers/thermal/broadcom/sr-thermal.c @@ -60,6 +60,9 @@ static int sr_thermal_probe(struct platform_device *pdev) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENOENT; + sr_thermal->regs = (void __iomem *)devm_memremap(&pdev->dev, res->start, resource_size(res), MEMREMAP_WB); -- 2.35.1