Re: [PATCH] hwmon: (lm78) Fix overflow problems seen when writing large limits

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

 



On 07/29/2014 09:32 PM, Axel Lin wrote:
2014-07-30 11:52 GMT+08:00 Guenter Roeck <linux@xxxxxxxxxxxx>:
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.

Cc: Axel Lin <axel.lin@xxxxxxxxxx>
Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
The patch looks good to me, so
Reviewed-by: Axel Lin <axel.lin@xxxxxxxxxx>

Thanks!

BTW, seems other drivers have similar issue:
$ grep "TEMP_TO_REG(int" drivers/hwmon/*.c
drivers/hwmon/dme1737.c:static inline int TEMP_TO_REG(int val)
drivers/hwmon/lm77.c:static inline s16 LM77_TEMP_TO_REG(int temp)
drivers/hwmon/lm78.c:static inline s8 TEMP_TO_REG(int val)
drivers/hwmon/lm92.c:static inline s16 TEMP_TO_REG(int val)
drivers/hwmon/sis5595.c:static inline s8 TEMP_TO_REG(int val)
drivers/hwmon/smsc47m192.c:static inline s8 TEMP_TO_REG(int val)


I usually find those problems when running module tests; one of the tests
explicitly tries to trigger this kind of overflow (long -> int).
Works pretty well...

Add lm85 to the list, with several issues all over the place. I am right
now working on that one. The smsc47m192 problem is already fixed; I found
that when I tested your patch. Patches for the others are welcome :-).
Those would take a bit to apply, though, since I'll want to have
module tests to ensure that the drivers don't have any other problems.

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