Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp439741iog; Mon, 13 Jun 2022 06:03:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySp9wYal/eiRUqPA8mBf0Vhv1sbo5Nz6QyDhIXVWVUhaqAxvERuME4El1OIf9jFcK6k62l X-Received: by 2002:a17:906:130c:b0:715:785b:b624 with SMTP id w12-20020a170906130c00b00715785bb624mr8236543ejb.331.1655125420897; Mon, 13 Jun 2022 06:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125420; cv=none; d=google.com; s=arc-20160816; b=ytMIP7TWYseGEcwoYwIZb37wtTptlWHFQIeYMPtjqXpCV/SKDpa7rzdNLTD1RY+wW4 OwuJdaTSfCNGb4pZo9XotRIhBjB6kF3MVksQpRpTbhrlBvTCx5l2t/Mb/6Nv4jwTyysu q9n/fvDPF0EZBJ/FN6rKMIHDQGXQC0TMITebI2tF9AOsvcQbxDX22NdCOT98Y7t5tutS Bw/5+PBr9cq5baj1HZZX02DQQd8FL5HEaOlEm9mvtFc3J621ILTfia5n23v0PYeL4n+q ns2VY1GXIu7fkJxcDtrhXIWYC3+IgXOSQpvnkEUhJwyi2XHA6q5w8x7M487qr3bUklEs GLSw== 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=ZQt6WfuLvNAIERXdwXtJPxFJ0nvQE19tAi7adIIBMvHc5/hBTjFiK7u81dQPbKLnK3 O24bGWO9gz1Z70jDXkBu9Rb/qh/PAeCvdC0RFZEH+IR6LFeEvUzZ9S2BdjNR9zyjU5Ad 71VLGyifWLRpX9KymRkfw7ZDkPv8feVS+mmc8UDGD1xqsqlE+GZmhCu8W0BC2dEbh3KK JY8rSqyBVdRQsw0/5DZvoefJmed0FThokfwsbjl78jDzidDOnXanL0cgiSC6jIIQpjPZ qKko8LUS+J17mQHxC4eNPSwTsZcp3UAOYCFcNrBYi+rDOd8nqyzJGVgl6wiI4H3Btu/T WD0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ePrL+w1/"; 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 w17-20020a056402269100b0042b30589cbcsi9717255edd.249.2022.06.13.06.03.13; Mon, 13 Jun 2022 06:03:40 -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="ePrL+w1/"; 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 S1352780AbiFMLV4 (ORCPT + 99 others); Mon, 13 Jun 2022 07:21:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353635AbiFMLQI (ORCPT ); Mon, 13 Jun 2022 07:16:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9FFF387BF; Mon, 13 Jun 2022 03:38:38 -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 872CCB80EA8; Mon, 13 Jun 2022 10:38:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6C5CC34114; Mon, 13 Jun 2022 10:38:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116716; bh=7gLmPXzMhNy7D2VimkqVQcs4oFEM8KSRbDToOpCrFlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ePrL+w1/es/rMuAXu+t7BghilnrFjpmT6wTZ4zB+9dEb01lVQZPBF4UZidPxeNg5e qAN0y+dGMfUtH4Jw2VzlRyl9YXusKDdSxvXiFQYR6c7nlJukl4MIf0PINxfnlHPquW A29WyU/Vk/9ClAEmoYQxq3vvmh6UobPcyYSkErKM= 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.4 147/411] thermal/drivers/broadcom: Fix potential NULL dereference in sr_thermal_probe Date: Mon, 13 Jun 2022 12:07:00 +0200 Message-Id: <20220613094933.076080458@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@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=-8.3 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: 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