It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value. Fixes: 0772a6407939 ("hwmon: New driver sch5636") Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx> --- drivers/hwmon/sch5636.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/sch5636.c b/drivers/hwmon/sch5636.c index 269757bc3a9e..6fc471168af8 100644 --- a/drivers/hwmon/sch5636.c +++ b/drivers/hwmon/sch5636.c @@ -394,13 +394,17 @@ static int sch5636_probe(struct platform_device *pdev) struct sch5636_data *data; int i, err, val, revision[2]; char id[4]; + struct resource *res; data = devm_kzalloc(&pdev->dev, sizeof(struct sch5636_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; mutex_init(&data->update_lock); platform_set_drvdata(pdev, data); -- 2.25.1