projects
/
GitHub
/
MotorolaMobilityLLC
/
kernel-slsi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e36ce99
)
hwmon: (smsc47m192) Fix overflows seen when writing into limit attributes
author
Guenter Roeck
<linux@roeck-us.net>
Sun, 20 Nov 2016 22:16:16 +0000
(14:16 -0800)
committer
Guenter Roeck
<linux@roeck-us.net>
Sat, 10 Dec 2016 05:54:05 +0000
(21:54 -0800)
Module test reports overflows when writing into temperature and voltage
limit attributes
temp1_min: Suspected overflow: [127000 vs. 0]
temp1_max: Suspected overflow: [127000 vs. 0]
temp1_offset: Suspected overflow: [127000 vs. 0]
temp2_min: Suspected overflow: [127000 vs. 0]
temp2_max: Suspected overflow: [127000 vs. 0]
temp2_offset: Suspected overflow: [127000 vs. 0]
temp3_min: Suspected overflow: [127000 vs. 0]
temp3_max: Suspected overflow: [127000 vs. 0]
temp3_offset: Suspected overflow: [127000 vs. 0]
in0_min: Suspected overflow: [3320 vs. 0]
in0_max: Suspected overflow: [3320 vs. 0]
in4_min: Suspected overflow: [15938 vs. 0]
in4_max: Suspected overflow: [15938 vs. 0]
in6_min: Suspected overflow: [1992 vs. 0]
in6_max: Suspected overflow: [1992 vs. 0]
in7_min: Suspected overflow: [2391 vs. 0]
in7_max: Suspected overflow: [2391 vs. 0]
The problem is caused by conversions from unsigned long to long and
from long to int.
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/smsc47m192.c
patch
|
blob
|
blame
|
history
diff --git
a/drivers/hwmon/smsc47m192.c
b/drivers/hwmon/smsc47m192.c
index 6ac7cda72d4cbe8ec3bfa628d7e5fdf266d2c731..15650f2476791192d4025a297e052e8d36c9fa80 100644
(file)
--- a/
drivers/hwmon/smsc47m192.c
+++ b/
drivers/hwmon/smsc47m192.c
@@
-77,14
+77,15
@@
static inline unsigned int IN_FROM_REG(u8 reg, int n)
static inline u8 IN_TO_REG(unsigned long val, int n)
{
- return clamp_val(SCALE(val, 192, nom_mv[n]), 0, 255);
+ val = clamp_val(val, 0, nom_mv[n] * 255 / 192);
+ return SCALE(val, 192, nom_mv[n]);
}
/*
* TEMP: 0.001 degC units (-128C to +127C)
* REG: 1C/bit, two's complement
*/
-static inline s8 TEMP_TO_REG(
int
val)
+static inline s8 TEMP_TO_REG(
long
val)
{
return SCALE(clamp_val(val, -128000, 127000), 1, 1000);
}