This is a note to let you know that I've just added the patch titled hwmon: (lm85) Fix various errors on attribute writes to the 3.16-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: hwmon-lm85-fix-various-errors-on-attribute-writes.patch and it can be found in the queue-3.16 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 3248c3b771ddd9d31695da17ba350eb6e1b80a53 Mon Sep 17 00:00:00 2001 From: Guenter Roeck <linux@xxxxxxxxxxxx> Date: Tue, 29 Jul 2014 22:23:12 -0700 Subject: hwmon: (lm85) Fix various errors on attribute writes From: Guenter Roeck <linux@xxxxxxxxxxxx> commit 3248c3b771ddd9d31695da17ba350eb6e1b80a53 upstream. Temperature limit register writes did not account for negative numbers. As a result, writing -127000 resulted in -126000 written into the temperature limit register. This problem affected temp[1-3]_min, temp[1-3]_max, temp[1-3]_auto_temp_crit, and temp[1-3]_auto_temp_min. When writing pwm[1-3]_freq, a long variable was auto-converted into an int without range check. Wiring values larger than MAXINT resulted in unexpected register values. When writing temp[1-3]_auto_temp_max, an unsigned long variable was auto-converted into an int without range check. Writing values larger than MAXINT resulted in unexpected register values. vrm is an u8, so the written value needs to be limited to [0, 255]. Cc: Axel Lin <axel.lin@xxxxxxxxxx> Reviewed-by: Axel Lin <axel.lin@xxxxxxxxxx> Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/hwmon/lm85.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -155,7 +155,7 @@ static inline u16 FAN_TO_REG(unsigned lo /* Temperature is reported in .001 degC increments */ #define TEMP_TO_REG(val) \ - clamp_val(SCALE(val, 1000, 1), -127, 127) + DIV_ROUND_CLOSEST(clamp_val((val), -127000, 127000), 1000) #define TEMPEXT_FROM_REG(val, ext) \ SCALE(((val) << 4) + (ext), 16, 1000) #define TEMP_FROM_REG(val) ((val) * 1000) @@ -189,7 +189,7 @@ static const int lm85_range_map[] = { 13300, 16000, 20000, 26600, 32000, 40000, 53300, 80000 }; -static int RANGE_TO_REG(int range) +static int RANGE_TO_REG(long range) { int i; @@ -211,7 +211,7 @@ static const int adm1027_freq_map[8] = { 11, 15, 22, 29, 35, 44, 59, 88 }; -static int FREQ_TO_REG(const int *map, int freq) +static int FREQ_TO_REG(const int *map, unsigned long freq) { int i; @@ -460,6 +460,9 @@ static ssize_t store_vrm_reg(struct devi if (err) return err; + if (val > 255) + return -EINVAL; + data->vrm = val; return count; } Patches currently in stable-queue which might be from linux@xxxxxxxxxxxx are queue-3.16/hwmon-sis5595-prevent-overflow-problem-when-writing-large-limits.patch queue-3.16/hwmon-ads1015-fix-off-by-one-for-valid-channel-index-checking.patch queue-3.16/hwmon-lm78-fix-overflow-problems-seen-when-writing-large-temperature-limits.patch queue-3.16/hwmon-gpio-fan-prevent-overflow-problem-when-writing-large-limits.patch queue-3.16/hwmon-amc6821-fix-possible-race-condition-bug.patch queue-3.16/hwmon-ads1015-fix-out-of-bounds-array-access.patch queue-3.16/hwmon-dme1737-prevent-overflow-problem-when-writing-large-limits.patch queue-3.16/hwmon-lm92-prevent-overflow-problem-when-writing-large-limits.patch queue-3.16/hwmon-lm85-fix-various-errors-on-attribute-writes.patch -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html