diff mbox series

thermal: broadcom: Fix potential NULL dereference in sr_thermal_probe

Message ID 20220425092929.90412-1-zhengyongjun3@huawei.com (mailing list archive)
State New, archived
Delegated to: Daniel Lezcano
Headers show
Series thermal: broadcom: Fix potential NULL dereference in sr_thermal_probe | expand

Commit Message

Zheng Yongjun April 25, 2022, 9:29 a.m. UTC
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>
---
 drivers/thermal/broadcom/sr-thermal.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Daniel Lezcano April 25, 2022, 6:25 p.m. UTC | #1
On 25/04/2022 11:29, Zheng Yongjun wrote:
> 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>
> ---

Applied, thanks
diff mbox series

Patch

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);