All of lore.kernel.org
 help / color / mirror / Atom feed
From: "thermal-bot for Zheng Yongjun" <tip-bot2@linutronix.de>
To: linux-pm@vger.kernel.org
Cc: Zheng Yongjun <zhengyongjun3@huawei.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	rui.zhang@intel.com, amitk@kernel.org
Subject: [thermal: thermal/next] thermal/drivers/broadcom: Fix potential NULL dereference in sr_thermal_probe
Date: Thu, 19 May 2022 12:44:13 -0000	[thread overview]
Message-ID: <165296425371.4207.10296133140962930839.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20220425092929.90412-1-zhengyongjun3@huawei.com>

The following commit has been merged into the thermal/next branch of thermal:

Commit-ID:     e20d136ec7d6f309989c447638365840d3424c8e
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//e20d136ec7d6f309989c447638365840d3424c8e
Author:        Zheng Yongjun <zhengyongjun3@huawei.com>
AuthorDate:    Mon, 25 Apr 2022 09:29:29 
Committer:     Daniel Lezcano <daniel.lezcano@linaro.org>
CommitterDate: Thu, 19 May 2022 12:11:52 +02:00

thermal/drivers/broadcom: Fix potential NULL dereference in sr_thermal_probe

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 <zhengyongjun3@huawei.com>
Link: https://lore.kernel.org/r/20220425092929.90412-1-zhengyongjun3@huawei.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 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 475ce29..85ab9ed 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);

      parent reply	other threads:[~2022-05-19 12:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-25  9:29 [PATCH] thermal: broadcom: Fix potential NULL dereference in sr_thermal_probe Zheng Yongjun
2022-04-25 18:25 ` Daniel Lezcano
2022-05-19 12:44 ` thermal-bot for Zheng Yongjun [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=165296425371.4207.10296133140962930839.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=amitk@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=zhengyongjun3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.