Re: [PATCH] hwmon: (dme1737) Prevent overflow problem when writing large limits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Aug 02, 2014 at 10:14:47AM +0800, Axel Lin wrote:
> On platforms with sizeof(int) < sizeof(long), writing a temperature
> limit larger than MAXINT will result in unpredictable limit values
> written to the chip. Avoid auto-conversion from long to int to fix
> the problem.
> 
> Signed-off-by: Axel Lin <axel.lin@xxxxxxxxxx>
> ---
>  drivers/hwmon/dme1737.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c
> index 4ae3fff..e9cd1e2 100644
> --- a/drivers/hwmon/dme1737.c
> +++ b/drivers/hwmon/dme1737.c
> @@ -293,7 +293,7 @@ static inline int TEMP_FROM_REG(int reg, int res)
>  	return (reg * 1000) >> (res - 8);
>  }
>  
> -static inline int TEMP_TO_REG(int val)
> +static inline int TEMP_TO_REG(long val)
>  {
>  	return clamp_val((val < 0 ? val - 500 : val + 500) / 1000, -128, 127);
>  }

Hi Axel,

the problem is not just limietd to temperatures. Voltage limits,
fan minimum speed, pwm frequency, pwm ramp rate, and possibly other
attributes have the same problem.

Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors




[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux