[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220422091207.4034406-2-yangyingliang@huawei.com>
Date: Fri, 22 Apr 2022 17:11:48 +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 01/20] hwmon: (abituguru) 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: f2b84bbcebfd ("[PATCH] abituguru: New hardware monitoring driver")
Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
---
drivers/hwmon/abituguru.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/abituguru.c b/drivers/hwmon/abituguru.c
index 681f0623868f..58595567440c 100644
--- a/drivers/hwmon/abituguru.c
+++ b/drivers/hwmon/abituguru.c
@@ -1259,6 +1259,7 @@ static int abituguru_probe(struct platform_device *pdev)
struct abituguru_data *data;
int i, j, used, sysfs_names_free, sysfs_attr_i, res = -ENODEV;
char *sysfs_filename;
+ struct resource *r;
/*
* El weirdo probe order, to keep the sysfs order identical to the
@@ -1273,7 +1274,10 @@ static int abituguru_probe(struct platform_device *pdev)
if (!data)
return -ENOMEM;
- data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start;
+ r = platform_get_resource(pdev, IORESOURCE_IO, 0);
+ if (!r)
+ return -EINVAL;
+ data->addr = r->start;
mutex_init(&data->update_lock);
platform_set_drvdata(pdev, data);
--
2.25.1
Powered by blists - more mailing lists