Re: [PATCH 02/17] hwmon: (ds620) Fix overflows seen when writing temperature limits

2016-12-08 Thread Jean Delvare
On Sun,  4 Dec 2016 20:55:25 -0800, Guenter Roeck wrote:
> Module test reports:
> 
> temp1_max: Suspected overflow: [16 vs. 0]
> temp1_min: Suspected overflow: [16 vs. 0]
> 
> This is seen because the values passed when writing temperature limits
> are unbound.
> 
> Signed-off-by: Guenter Roeck 
> ---
>  drivers/hwmon/ds620.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 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;

Reviewed-by: Jean Delvare 
Fixes: 6099469805c2 ("hwmon: Support for Dallas Semiconductor DS620")

-- 
Jean Delvare
SUSE L3 Support
--
To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/17] hwmon: (ds620) Fix overflows seen when writing temperature limits

2016-12-04 Thread Guenter Roeck
Module test reports:

temp1_max: Suspected overflow: [16 vs. 0]
temp1_min: Suspected overflow: [16 vs. 0]

This is seen because the values passed when writing temperature limits
are unbound.

Signed-off-by: Guenter Roeck 
---
 drivers/hwmon/ds620.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html