summaryrefslogtreecommitdiff
path: root/drivers/hwmon/hwmon.c
diff options
context:
space:
mode:
authorPaul Cercueil <paul@crapouillou.net>2022-01-31 16:27:40 +0000
committerGuenter Roeck <linux@roeck-us.net>2022-02-27 17:03:17 -0800
commit07320c91565658e117f2f86a190eec9bb64abeb6 (patch)
treea749d22d51267b70713a2167a660512f01d0c830 /drivers/hwmon/hwmon.c
parent9f93aa1005fa1b960f10e0ee3ed8c4e697526053 (diff)
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 <paul@crapouillou.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/hwmon.c')
-rw-r--r--drivers/hwmon/hwmon.c2
1 files changed, 1 insertions, 1 deletions
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;