Commit e2c26f05 authored by Guenter Roeck's avatar Guenter Roeck

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: default avatarGuenter Roeck <linux@roeck-us.net>
Reviewed-by: default avatarJean Delvare <jdelvare@suse.de>
parent 3a05633b
......@@ -312,7 +312,9 @@ static ssize_t set_temp_crit_hyst(struct device *dev,
if (kstrtoul(buf, 10, &val) < 0)
return -EINVAL;
val = clamp_val(val, 0, JC42_TEMP_MAX);
diff = jc42_temp_from_reg(data->temp[t_crit]) - val;
hyst = 0;
if (diff > 0) {
if (diff < 2250)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment