@@ -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);
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@huawei.com> --- drivers/hwmon/abituguru.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)