summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2016-12-03 11:07:14 -0800
committerGuenter Roeck <linux@roeck-us.net>2016-12-09 21:54:28 -0800
commit7cb53e28b03006fa655632fe07b27a862f3f5cb5 (patch)
treefa0877d08534be6fcc5beae3853dbdac78777ba6 /drivers
parentdf60d7013c36f86f7653af387915019d7da49613 (diff)
hwmon: (adm1025) Fix overflows seen when writing voltage limits
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')
-rw-r--r--drivers/hwmon/adm1025.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c
index d6c767ace916..1abb4609b412 100644
--- a/drivers/hwmon/adm1025.c
+++ b/drivers/hwmon/adm1025.c
@@ -93,7 +93,7 @@ static const int in_scale[6] = { 2500, 2250, 3300, 5000, 12000, 3300 };
#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)