summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorLucas Magasweran <lucas.magasweran@ieee.org>2018-05-08 13:43:33 +0200
committerGuenter Roeck <linux@roeck-us.net>2018-05-21 16:51:59 +0200
commit59df4f4e8e0b9a0abb14ad5128d36d844c3e2689 (patch)
treeb58746d6b637b1a1100dbe5e15006317dfb54bf1 /drivers/hwmon
parenthwmon: (fschmd) fix typo 'can by' to 'can be' (diff)
downloadlinux-59df4f4e8e0b9a0abb14ad5128d36d844c3e2689.tar.xz
linux-59df4f4e8e0b9a0abb14ad5128d36d844c3e2689.zip
hwmon: (core) check parent dev != NULL when chip != NULL
hwmon_device_register_with_info() registration API requires a non-NULL parent device when chip is non-NULL. This commit adds a check and documents this requirement. Signed-off-by: Lucas Magasweran <lucas.magasweran@ieee.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/hwmon.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 32083e452cde..e88c01961948 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -698,6 +698,9 @@ hwmon_device_register_with_info(struct device *dev, const char *name,
if (chip && (!chip->ops || !chip->ops->is_visible || !chip->info))
return ERR_PTR(-EINVAL);
+ if (chip && !dev)
+ return ERR_PTR(-EINVAL);
+
return __hwmon_device_register(dev, name, drvdata, chip, extra_groups);
}
EXPORT_SYMBOL_GPL(hwmon_device_register_with_info);