aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hwmon/hwmon.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index e176a43af63d..a26c385a435b 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -22,6 +22,7 @@
22#include <linux/gfp.h> 22#include <linux/gfp.h>
23#include <linux/spinlock.h> 23#include <linux/spinlock.h>
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/string.h>
25 26
26#define HWMON_ID_PREFIX "hwmon" 27#define HWMON_ID_PREFIX "hwmon"
27#define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d" 28#define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d"
@@ -99,6 +100,10 @@ hwmon_device_register_with_groups(struct device *dev, const char *name,
99 struct hwmon_device *hwdev; 100 struct hwmon_device *hwdev;
100 int err, id; 101 int err, id;
101 102
103 /* Do not accept invalid characters in hwmon name attribute */
104 if (name && (!strlen(name) || strpbrk(name, "-* \t\n")))
105 return ERR_PTR(-EINVAL);
106
102 id = ida_simple_get(&hwmon_ida, 0, 0, GFP_KERNEL); 107 id = ida_simple_get(&hwmon_ida, 0, 0, GFP_KERNEL);
103 if (id < 0) 108 if (id < 0)
104 return ERR_PTR(id); 109 return ERR_PTR(id);