aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/jc42.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2015-01-19 12:16:53 -0500
committerGuenter Roeck <linux@roeck-us.net>2015-01-26 00:23:59 -0500
commite2c26f058e31619b548046b84fe2c2116cb5016f (patch)
tree889f1f0e0b4c96ca91eb35972d5afa1131022c19 /drivers/hwmon/jc42.c
parent3a05633b042fb4aea65b09ce2d0d43689df6eb9a (diff)
hwmon: (jc42) Fix integer overflow when writing hysteresis value
Subtracting an unsigned long from a signed value causes an overflow with large values. Use clamp_val() to reduce the number range prior to subtracting it from the temperature limit. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Jean Delvare <jdelvare@suse.de>
Diffstat (limited to 'drivers/hwmon/jc42.c')
-rw-r--r--drivers/hwmon/jc42.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/hwmon/jc42.c b/drivers/hwmon/jc42.c
index f8e3bbbf019c..a46cb65cacb5 100644
--- a/drivers/hwmon/jc42.c
+++ b/drivers/hwmon/jc42.c
@@ -312,7 +312,9 @@ static ssize_t set_temp_crit_hyst(struct device *dev,
312 if (kstrtoul(buf, 10, &val) < 0) 312 if (kstrtoul(buf, 10, &val) < 0)
313 return -EINVAL; 313 return -EINVAL;
314 314
315 val = clamp_val(val, 0, JC42_TEMP_MAX);
315 diff = jc42_temp_from_reg(data->temp[t_crit]) - val; 316 diff = jc42_temp_from_reg(data->temp[t_crit]) - val;
317
316 hyst = 0; 318 hyst = 0;
317 if (diff > 0) { 319 if (diff > 0) {
318 if (diff < 2250) 320 if (diff < 2250)