Skip to content

Commit

Permalink
hwmon: (lm87) Fix overflow seen when writing voltage limit attributes
Browse files Browse the repository at this point in the history
Writes into voltage limit attributes can overflow due to an unbound
multiplication.

Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Guenter Roeck committed Dec 12, 2016
1 parent c0d04e9 commit 12fa55c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/hwmon/lm87.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static u8 LM87_REG_TEMP_LOW[3] = { 0x3A, 0x38, 0x2C };

#define IN_FROM_REG(reg, scale) (((reg) * (scale) + 96) / 192)
#define IN_TO_REG(val, scale) ((val) <= 0 ? 0 : \
(val) * 192 >= (scale) * 255 ? 255 : \
(val) >= (scale) * 255 / 192 ? 255 : \
((val) * 192 + (scale) / 2) / (scale))

#define TEMP_FROM_REG(reg) ((reg) * 1000)
Expand Down

0 comments on commit 12fa55c

Please sign in to comment.