mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-11-08 10:31:43 +01:00
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 <[email protected]> Reviewed-by: Jean Delvare <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
This commit is contained in:
1 parent
768821a302
commit
648cd48c9e
1 file changed
+5
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user