aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2016-12-04 21:16:02 -0500
committerGuenter Roeck <linux@roeck-us.net>2016-12-12 14:33:42 -0500
commit12fa55ccc49df52617d7454ba448c1876e189bac (patch)
tree5eceb0df03440c77bb1a28a6aeaf26381644fc8a /drivers/hwmon
parentc0d04e9112ad59d73f23f3b0f6726c5e798dfcbf (diff)
hwmon: (lm87) Fix overflow seen when writing voltage limit attributes
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>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/lm87.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c
index 81cb898245a1..13cca3606e06 100644
--- a/drivers/hwmon/lm87.c
+++ b/drivers/hwmon/lm87.c
@@ -121,7 +121,7 @@ static u8 LM87_REG_TEMP_LOW[3] = { 0x3A, 0x38, 0x2C };
121 121
122#define IN_FROM_REG(reg, scale) (((reg) * (scale) + 96) / 192) 122#define IN_FROM_REG(reg, scale) (((reg) * (scale) + 96) / 192)
123#define IN_TO_REG(val, scale) ((val) <= 0 ? 0 : \ 123#define IN_TO_REG(val, scale) ((val) <= 0 ? 0 : \
124 (val) * 192 >= (scale) * 255 ? 255 : \ 124 (val) >= (scale) * 255 / 192 ? 255 : \
125 ((val) * 192 + (scale) / 2) / (scale)) 125 ((val) * 192 + (scale) / 2) / (scale))
126 126
127#define TEMP_FROM_REG(reg) ((reg) * 1000) 127#define TEMP_FROM_REG(reg) ((reg) * 1000)