linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: broadcom: check return value after calling platform_get_resource()
@ 2022-05-05 12:42 Yang Yingliang
  0 siblings, 0 replies; only message in thread
From: Yang Yingliang @ 2022-05-05 12:42 UTC (permalink / raw)
  To: linux-kernel, linux-pm; +Cc: rafael, daniel.lezcano

It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Fixes: 250e211057c7 ("thermal: broadcom: Add Stingray thermal driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/thermal/broadcom/sr-thermal.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/thermal/broadcom/sr-thermal.c b/drivers/thermal/broadcom/sr-thermal.c
index 475ce2900771..799128deb91c 100644
--- a/drivers/thermal/broadcom/sr-thermal.c
+++ b/drivers/thermal/broadcom/sr-thermal.c
@@ -60,6 +60,8 @@ static int sr_thermal_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -EINVAL;
 	sr_thermal->regs = (void __iomem *)devm_memremap(&pdev->dev, res->start,
 							 resource_size(res),
 							 MEMREMAP_WB);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-05 12:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 12:42 [PATCH] thermal: broadcom: check return value after calling platform_get_resource() Yang Yingliang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).