diff options
author | Guenter Roeck <linux@roeck-us.net> | 2016-12-03 11:10:34 -0800 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2016-12-09 21:54:32 -0800 |
commit | 64bd708ae0edced5eee764c2321b280bc1e16550 (patch) | |
tree | 4b07a781cd168dd86fa3e5905ed5a605e2262c5c /drivers/hwmon/adt7470.c | |
parent | b94793b4da1011f24321e2ecc5e173a7198358a5 (diff) | |
download | talos-obmc-linux-64bd708ae0edced5eee764c2321b280bc1e16550.tar.gz talos-obmc-linux-64bd708ae0edced5eee764c2321b280bc1e16550.zip |
hwmon: (adt7470) Fix overflows seen when writing into limit attributes
Fix overflows seen when writing large values into various temperature limit
attributes.
The input value passed to DIV_ROUND_CLOSEST() needs to be clamped to avoid
such overflows.
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/adt7470.c')
-rw-r--r-- | drivers/hwmon/adt7470.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c index 6e60ca53406e..c9a1d9c25572 100644 --- a/drivers/hwmon/adt7470.c +++ b/drivers/hwmon/adt7470.c @@ -483,8 +483,8 @@ static ssize_t set_temp_min(struct device *dev, if (kstrtol(buf, 10, &temp)) return -EINVAL; + temp = clamp_val(temp, -128000, 127000); temp = DIV_ROUND_CLOSEST(temp, 1000); - temp = clamp_val(temp, -128, 127); mutex_lock(&data->lock); data->temp_min[attr->index] = temp; @@ -517,8 +517,8 @@ static ssize_t set_temp_max(struct device *dev, if (kstrtol(buf, 10, &temp)) return -EINVAL; + temp = clamp_val(temp, -128000, 127000); temp = DIV_ROUND_CLOSEST(temp, 1000); - temp = clamp_val(temp, -128, 127); mutex_lock(&data->lock); data->temp_max[attr->index] = temp; @@ -880,8 +880,8 @@ static ssize_t set_pwm_tmin(struct device *dev, if (kstrtol(buf, 10, &temp)) return -EINVAL; + temp = clamp_val(temp, -128000, 127000); temp = DIV_ROUND_CLOSEST(temp, 1000); - temp = clamp_val(temp, -128, 127); mutex_lock(&data->lock); data->pwm_tmin[attr->index] = temp; |