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

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

 



2014-08-05 13:51 GMT+08:00 Guenter Roeck <linux@xxxxxxxxxxxx>:
> On Mon, Aug 04, 2014 at 09:44:21AM -0700, Guenter Roeck wrote:
>> 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.
>>
> Hi Axel,
>
> as followup on this, here is a complete set of test script results for
> this driver. Problematic are the suspected overflows as well as the
> min > max error when writing vrm (which is because writing a long variable
> into an u8 is rarely a good idea). This is without applying your patch;
> with it the temperature overflows should be fixed.
>
> Please let me know if you want/can take care of the problems.
> Otherwise I'll have a look myself later this week.
Hi Guenter,
I'll send v2 tomorrow.

Thanks,
Axel

_______________________________________________
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