Skip to contentSkip to conversation

hwmon: (jc42) Fix integer overflow

PATCH In review Guenter Roeck 2 participants 2 messages Jan 19, 2015 – Jan 23, 2015 Hardware monitoring

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 2/2 hwmon: (jc42) Fix integer overflow

Mixed use of long and int caused an integer overflow when writing large limits.

---
 drivers/hwmon/jc42.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/jc42.c +1 -1
index 262d808..f8e3bbb 100644
@@ -201,7 +201,7 @@ struct jc42_data {
 #define JC42_TEMP_MIN		0
 #define JC42_TEMP_MAX		125000
 
-static u16 jc42_temp_to_reg(int temp, bool extended)
+static u16 jc42_temp_to_reg(long temp, bool extended)
 {
 	int ntemp = clamp_val(temp,
 			      extended ? JC42_TEMP_MIN_EXTENDED :
Signature · 7 lines
2.1.0


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Reviewed-by on v1 2/2
#1 lore raw

Hi Guenter,

Quoted 12 lines · Guenter Roeck

Mixed use of long and int caused an integer overflow when writing large limits.

---
 drivers/hwmon/jc42.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/jc42.c +0 -0
index 262d808..f8e3bbb 100644

drivers/hwmon/jc42.c struct jc42_data { · line 207

Quoted 8 lines
drivers/hwmon/jc42.c +1 -1
@@ -201,7 +201,7 @@ struct jc42_data {
 #define JC42_TEMP_MIN		0
 #define JC42_TEMP_MAX		125000
 
-static u16 jc42_temp_to_reg(int temp, bool extended)
+static u16 jc42_temp_to_reg(long temp, bool extended)
 {
 	int ntemp = clamp_val(temp,
 			      extended ? JC42_TEMP_MIN_EXTENDED :

Good catch.

Signature · 7 lines
Jean Delvare
SUSE L3 Support

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors