projects
/
GitHub
/
LineageOS
/
android_kernel_motorola_exynos9610.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
12fa55c
)
hwmon: (lm85) Fix overflows seen when writing voltage limit attributes
author
Guenter Roeck
<linux@roeck-us.net>
Mon, 5 Dec 2016 02:16:48 +0000
(18:16 -0800)
committer
Guenter Roeck
<linux@roeck-us.net>
Mon, 12 Dec 2016 19:33:43 +0000
(11:33 -0800)
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>
drivers/hwmon/lm85.c
patch
|
blob
|
blame
|
history
diff --git
a/drivers/hwmon/lm85.c
b/drivers/hwmon/lm85.c
index 6ff773fcaefbece828fe3eb89f594fd71e532e13..29c8136ce9c50c5c90156cdb91915e642eabea35 100644
(file)
--- a/
drivers/hwmon/lm85.c
+++ b/
drivers/hwmon/lm85.c
@@
-136,7
+136,8
@@
static const int lm85_scaling[] = { /* .001 Volts */
#define SCALE(val, from, to) (((val) * (to) + ((from) / 2)) / (from))
#define INS_TO_REG(n, val) \
- clamp_val(SCALE(val, lm85_scaling[n], 192), 0, 255)
+ SCALE(clamp_val(val, 0, 255 * lm85_scaling[n] / 192), \
+ lm85_scaling[n], 192)
#define INSEXT_FROM_REG(n, val, ext) \
SCALE(((val) << 4) + (ext), 192 << 4, lm85_scaling[n])