[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220422091207.4034406-18-yangyingliang@huawei.com>
Date: Fri, 22 Apr 2022 17:12:04 +0800
From: Yang Yingliang <yangyingliang@...wei.com>
To: <linux-kernel@...r.kernel.org>, <linux-hwmon@...r.kernel.org>
CC: <linux@...ck-us.net>, <jdelvare@...e.com>
Subject: [PATCH 17/20] hwmon: (vt8231) check return value after calling platform_get_resource()
It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.
Fixes: ec5e1a4b8faa ("hwmon: Convert vt8231 to a platform driver")
Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
---
drivers/hwmon/vt8231.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
index 03275ac8ba72..394ba989b7ae 100644
--- a/drivers/hwmon/vt8231.c
+++ b/drivers/hwmon/vt8231.c
@@ -783,6 +783,8 @@ static int vt8231_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, VT8231_EXTENT,
vt8231_driver.driver.name)) {
dev_err(&pdev->dev, "Region 0x%lx-0x%lx already in use!\n",
--
2.25.1
Powered by blists - more mailing lists