Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Zheng Yongjun and committed by
Daniel Lezcano
e20d136e 077df623

+3
+3
drivers/thermal/broadcom/sr-thermal.c
··· 60 60 return -ENOMEM; 61 61 62 62 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 63 + if (!res) 64 + return -ENOENT; 65 + 63 66 sr_thermal->regs = (void __iomem *)devm_memremap(&pdev->dev, res->start, 64 67 resource_size(res), 65 68 MEMREMAP_WB);