It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value. Fixes: 45fb366940d5 ("hwmon: add support for Fintek F71882FG and F71883FG") Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx> --- drivers/hwmon/f71882fg.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index 938a8b9ec70d..33aec2a35e57 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c @@ -2336,13 +2336,17 @@ static int f71882fg_probe(struct platform_device *pdev) int err, i; int size; u8 start_reg, reg; + struct resource *res; data = devm_kzalloc(&pdev->dev, sizeof(struct f71882fg_data), GFP_KERNEL); if (!data) return -ENOMEM; - data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start; + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) + return -EINVAL; + data->addr = res->start; data->type = sio_data->type; data->temp_start = (data->type == f71858fg || data->type == f8000 || -- 2.25.1