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

From: Yang Yingliang
Date: Fri Apr 22 2022 - 05:00:43 EST


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

Fixes: 9de2e2e84e7d ("hwmon: Driver for Nuvoton NCT6775F, NCT6776F, and NCT6779D")
Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
---
drivers/hwmon/nct6775.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index 2b91f7e05126..d7479ba9636c 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -4027,6 +4027,8 @@ static int nct6775_probe(struct platform_device *pdev)

if (sio_data->access == access_direct) {
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+ if (!res)
+ return -EINVAL;
if (!devm_request_region(&pdev->dev, res->start, IOREGION_LENGTH,
DRVNAME))
return -EBUSY;
--
2.25.1