summaryrefslogtreecommitdiff
path: root/drivers/hwmon/emc2103.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2016-12-05 05:19:51 +0300
committerGuenter Roeck <linux@roeck-us.net>2016-12-12 22:33:43 +0300
commitca1b10b8250247fb5f241d1cb894c102203378bb (patch)
tree0f6621899fc6c0fcadd0a5886e36a2cd9f7f34e1 /drivers/hwmon/emc2103.c
parent67b2003485ee48dcfcb5338171defa4093bba02e (diff)
downloadlinux-ca1b10b8250247fb5f241d1cb894c102203378bb.tar.xz
hwmon: (emc2103) Fix overflows seen when temperature limit attributes
Writes into temperature limit attributes can overflow due to unbound values passed to DIV_ROUND_CLOSEST(). Cc: Steve Glendinning <steve.glendinning@shawell.net> Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/emc2103.c')
-rw-r--r--drivers/hwmon/emc2103.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
index 24e395c5907d..4b870ee9b0d3 100644
--- a/drivers/hwmon/emc2103.c
+++ b/drivers/hwmon/emc2103.c
@@ -251,7 +251,7 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *da,
if (result < 0)
return result;
- val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), -63, 127);
+ val = DIV_ROUND_CLOSEST(clamp_val(val, -63000, 127000), 1000);
mutex_lock(&data->update_lock);
data->temp_min[nr] = val;
@@ -273,7 +273,7 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *da,
if (result < 0)
return result;
- val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), -63, 127);
+ val = DIV_ROUND_CLOSEST(clamp_val(val, -63000, 127000), 1000);
mutex_lock(&data->update_lock);
data->temp_max[nr] = val;