diff mbox series

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

Message ID 20220422091207.4034406-10-yangyingliang@huawei.com (mailing list archive)
State Accepted
Headers show
Series hwmon: check return value after calling platform_get_resource() | expand

Commit Message

Yang Yingliang April 22, 2022, 9:11 a.m. UTC
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@huawei.com>
---
 drivers/hwmon/nct6775.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

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;