[PATCH 07/20] hwmon: (lm78) check return value after calling platform_get_resource()
From: Yang Yingliang
Date: Fri Apr 22 2022 - 05:00:38 EST
It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.
Fixes: c40769fee13c ("hwmon/lm78: No longer use i2c-isa")
Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
---
drivers/hwmon/lm78.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index 5e129cbec1cb..71c2a1bc75cc 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -792,6 +792,8 @@ static int lm78_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(dev, res->start + LM78_ADDR_REG_OFFSET,
2, "lm78"))
return -EBUSY;
--
2.25.1