[PATCH 20/20] hwmon: (w83781d) check return value after calling platform_get_resource()

From: Yang Yingliang
Date: Fri Apr 22 2022 - 05:01:31 EST


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

Fixes: 7666c13c627f ("hwmon/w83781d: No longer use i2c-isa")
Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
---
drivers/hwmon/w83781d.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index b3579721265f..4fe6eec02570 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -1767,6 +1767,8 @@ w83781d_isa_probe(struct platform_device *pdev)

/* Reserve the ISA region */
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+ if (!res)
+ return -EINVAL;
if (!devm_request_region(&pdev->dev,
res->start + W83781D_ADDR_REG_OFFSET, 2,
"w83781d"))
--
2.25.1