diff options
author | Guenter Roeck <linux@roeck-us.net> | 2014-02-28 18:37:55 (GMT) |
---|---|---|
committer | Matthew Weigel <Matthew.Weigel@freescale.com> | 2014-12-11 18:36:10 (GMT) |
commit | 4606e1f5e8101e0c99b1fc4cedc41dfe77117420 (patch) | |
tree | 629ebe54d967ac94fca84d2aef285aa95e573c1d /drivers/hwmon | |
parent | 4e9f0c4a3adf7800f06f3493cc6cd44ac7bef414 (diff) | |
download | linux-fsl-qoriq-4606e1f5e8101e0c99b1fc4cedc41dfe77117420.tar.xz |
hwmon: Do not accept invalid name attributes
hwmon name attributes must not include '-', as specified in
Documentation/hwmon/sysfs-interface. Also filter out spaces,
tabs, wildcards, and newline characters.
Tested-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
(cherry picked from commit 648cd48c9e566f53c5df30d79857e0937ae13b09)
Change-Id: Ib723f0a5304212bede9017bf63326aa2a59b6bc5
Reviewed-on: http://git.am.freescale.net:8181/19633
Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com>
Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/hwmon.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index e176a43..a26c385 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -22,6 +22,7 @@ #include <linux/gfp.h> #include <linux/spinlock.h> #include <linux/pci.h> +#include <linux/string.h> #define HWMON_ID_PREFIX "hwmon" #define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d" @@ -99,6 +100,10 @@ hwmon_device_register_with_groups(struct device *dev, const char *name, struct hwmon_device *hwdev; int err, id; + /* Do not accept invalid characters in hwmon name attribute */ + if (name && (!strlen(name) || strpbrk(name, "-* \t\n"))) + return ERR_PTR(-EINVAL); + id = ida_simple_get(&hwmon_ida, 0, 0, GFP_KERNEL); if (id < 0) return ERR_PTR(id); |