aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/ds620.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2016-11-20 10:37:39 -0800
committerGuenter Roeck <linux@roeck-us.net>2016-12-09 06:09:34 -0800
commite36ce99ee0815d7919a7b589bfb66f3de50b6bc7 (patch)
tree288bdd6a2ec0050ea208ef2558c66c92b5960d53 /drivers/hwmon/ds620.c
parenthwmon: (adm9240) Fix overflows seen when writing into limit attributes (diff)
downloadlinux-dev-e36ce99ee0815d7919a7b589bfb66f3de50b6bc7.tar.xz
linux-dev-e36ce99ee0815d7919a7b589bfb66f3de50b6bc7.zip
hwmon: (ds620) Fix overflows seen when writing temperature limits
Module test reports: temp1_max: Suspected overflow: [160000 vs. 0] temp1_min: Suspected overflow: [160000 vs. 0] This is seen because the values passed when writing temperature limits are unbound. Reviewed-by: Jean Delvare <jdelvare@suse.de> Fixes: 6099469805c2 ("hwmon: Support for Dallas Semiconductor DS620") Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/ds620.c')
-rw-r--r--drivers/hwmon/ds620.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hwmon/ds620.c b/drivers/hwmon/ds620.c
index edf550fc4eef..0043a4c02b85 100644
--- a/drivers/hwmon/ds620.c
+++ b/drivers/hwmon/ds620.c
@@ -166,7 +166,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
if (res)
return res;
- val = (val * 10 / 625) * 8;
+ val = (clamp_val(val, -128000, 128000) * 10 / 625) * 8;
mutex_lock(&data->update_lock);
data->temp[attr->index] = val;