Message ID | 20220422091207.4034406-20-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/w83627hf.c b/drivers/hwmon/w83627hf.c index 9be277156ed2..9d370d73d39d 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -1407,6 +1407,8 @@ static int w83627hf_probe(struct platform_device *pdev) }; res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) + return -EINVAL; if (!devm_request_region(dev, res->start, WINB_REGION_SIZE, DRVNAME)) { dev_err(dev, "Failed to request region 0x%lx-0x%lx\n", (unsigned long)res->start,
It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value. Fixes: 787c72b10788 ("hwmon/w83627hf: Convert to a platform driver") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- drivers/hwmon/w83627hf.c | 2 ++ 1 file changed, 2 insertions(+)