From 07320c91565658e117f2f86a190eec9bb64abeb6 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Mon, 31 Jan 2022 16:27:40 +0000 Subject: hwmon: Fix possible NULL pointer The recent addition of the label attribute added some code that read the "label" device property, without checking first that "dev" was non-NULL. Fix this issue by first checking that "dev" is non-NULL. Fixes: ccd98cba6a18 ("hwmon: Add "label" attribute") Signed-off-by: Paul Cercueil Signed-off-by: Guenter Roeck --- drivers/hwmon/hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/hwmon/hwmon.c') diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 6c3a8c65390d..0d6c6809f26c 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -809,7 +809,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, hdev->groups = groups; } - if (device_property_present(dev, "label")) { + if (dev && device_property_present(dev, "label")) { err = device_property_read_string(dev, "label", &label); if (err < 0) goto free_hwmon; -- cgit v1.2.3