Message ID | 20220422091207.4034406-5-yangyingliang@huawei.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | hwmon: check return value after calling platform_get_resource() | expand |
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c index 7f20edb0677c..7d88e7647074 100644 --- a/drivers/hwmon/f71805f.c +++ b/drivers/hwmon/f71805f.c @@ -1384,6 +1384,8 @@ static int f71805f_probe(struct platform_device *pdev) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) + return -EINVAL; if (!devm_request_region(&pdev->dev, res->start + ADDR_REG_OFFSET, 2, DRVNAME)) { dev_err(&pdev->dev, "Failed to request region 0x%lx-0x%lx\n",
It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value. Fixes: e53004e20a58 ("[PATCH] hwmon: New f71805f driver") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- drivers/hwmon/f71805f.c | 2 ++ 1 file changed, 2 insertions(+)