Skip to contentSkip to conversation

hwmon: (lm87) Fix vrm value range

PATCH Superseded Guenter Roeck 2 participants 3 messages Jan 24, 2012 – Jan 25, 2012 Hardware monitoring

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 5/79 hwmon: (lm87) Fix vrm value range

When updating vrm, the value range was not limited. This could result in more or less random vrm values if the value provided by the user was larger than 255. Fix by limiting the range to 0..255 using the SENSORS_LIMIT macro.

---
 drivers/hwmon/lm87.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/hwmon/lm87.c +1 -1
index 8e66f99..2aa5e1a 100644
@@ -604,7 +604,7 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr,
 	err = kstrtoul(buf, 10, &val);
 	if (err)
 		return err;
-	data->vrm = val;
+	data->vrm = SENSORS_LIMIT(val, 0, 255);
 	return count;
 }
 static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
Signature · 7 lines
1.7.3.1


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#1 lore raw
Quoted 15 lines · Guenter Roeck

When updating vrm, the value range was not limited. This could result in more or less random vrm values if the value provided by the user was larger than 255. Fix by limiting the range to 0..255 using the SENSORS_LIMIT macro.

---
 drivers/hwmon/lm87.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/hwmon/lm87.c +0 -0
index 8e66f99..2aa5e1a 100644

drivers/hwmon/lm87.c static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, · line 610

Quoted 8 lines
drivers/hwmon/lm87.c +1 -1
@@ -604,7 +604,7 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr,
 	err = kstrtoul(buf, 10, &val);
 	if (err)
 		return err;
-	data->vrm = val;
+	data->vrm = SENSORS_LIMIT(val, 0, 255);
 	return count;
 }
 static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);

Same concerns here as in it87, of course. I suggest you withdraw these patches for the time being.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#2 lore raw
In reply to Guenter Roeck
Quoted 11 lines · Jean Delvare
Quoted 10 lines · Guenter Roeck

When updating vrm, the value range was not limited. This could result in more or less random vrm values if the value provided by the user was larger than 255. Fix by limiting the range to 0..255 using the SENSORS_LIMIT macro.

---
 drivers/hwmon/lm87.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 17 lines

drivers/hwmon/lm87.c static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, · line 610

Quoted 13 lines
drivers/hwmon/lm87.c +1 -1
index 8e66f99..2aa5e1a 100644
@@ -604,7 +604,7 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr,
 	err = kstrtoul(buf, 10, &val);
 	if (err)
 		return err;
-	data->vrm = val;
+	data->vrm = SENSORS_LIMIT(val, 0, 255);
 	return count;
 }
 static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);

Same concerns here as in it87, of course. I suggest you withdraw these patches for the time being.

Agreed, makes sense. I'll move those to my "staging" branch for now.

I have a RFC set of patches in the works for hwmon-vid, trying to start addressing the vrm issue. We can go from there once we decided how to handle it.

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors