[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220422091207.4034406-14-yangyingliang@huawei.com>
Date: Fri, 22 Apr 2022 17:12:00 +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 13/20] hwmon: (smsc47b397) 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: 292fc1a5ff44 ("hwmon/smsc47b397: Convert to a platform driver")
Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
---
drivers/hwmon/smsc47b397.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index c26d6eae0e4e..07c04780f871 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -224,6 +224,8 @@ static int smsc47b397_probe(struct platform_device *pdev)
struct resource *res;
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+ if (!res)
+ return -EINVAL;
if (!devm_request_region(dev, res->start, SMSC_EXTENT,
smsc47b397_driver.driver.name)) {
dev_err(dev, "Region 0x%lx-0x%lx already in use!\n",
--
2.25.1
Powered by blists - more mailing lists