Skip to contentSkip to conversation

hwmon: (nct7802) Fix integer overflow seen when writing voltage limits

PATCH In review Guenter Roeck 2 participants 3 messages Jul 4, 2015 – Jul 6, 2015 Hardware monitoring

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 1/1 hwmon: (nct7802) Fix integer overflow seen when writing voltage limits

Writing a large value into a voltage limit attribute can result in an overflow due to an auto-conversion from unsigned long to unsigned int.

Cc Constantine Shulyupin <[email protected]>
---
 drivers/hwmon/nct7802.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/nct7802.c +1 -1
index 658bc91033a2..457b0f2678a4 100644
@@ -262,7 +262,7 @@ abort:
 }
 
 static int nct7802_write_voltage(struct nct7802_data *data, int nr, int index,
-				 unsigned int voltage)
+				 unsigned long voltage)
 {
 	int shift = 8 - REG_VOLTAGE_LIMIT_MSB_SHIFT[index - 1][nr];
 	int err;
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 1/1
#1 lore raw
Quoted 15 lines · Guenter Roeck

Writing a large value into a voltage limit attribute can result in an overflow due to an auto-conversion from unsigned long to unsigned int.

Cc Constantine Shulyupin <[email protected]>
---
 drivers/hwmon/nct7802.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/nct7802.c +0 -0
index 658bc91033a2..457b0f2678a4 100644

drivers/hwmon/nct7802.c abort: · line 268

Quoted 8 lines
drivers/hwmon/nct7802.c +1 -1
@@ -262,7 +262,7 @@ abort:
 }
 
 static int nct7802_write_voltage(struct nct7802_data *data, int nr, int index,
-				 unsigned int voltage)
+				 unsigned long voltage)
 {
 	int shift = 8 - REG_VOLTAGE_LIMIT_MSB_SHIFT[index - 1][nr];
 	int err;

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
author maintainer
#2 lore raw
In reply to Guenter Roeck

Hi Jean,

Quoted 27 lines · Jean Delvare
Quoted 15 lines · Guenter Roeck

Writing a large value into a voltage limit attribute can result in an overflow due to an auto-conversion from unsigned long to unsigned int.

Cc Constantine Shulyupin <[email protected]>
---
  drivers/hwmon/nct7802.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/nct7802.c +0 -0
index 658bc91033a2..457b0f2678a4 100644

drivers/hwmon/nct7802.c abort: · line 268

Quoted 8 lines
drivers/hwmon/nct7802.c +1 -1
@@ -262,7 +262,7 @@ abort:
  }
 
  static int nct7802_write_voltage(struct nct7802_data *data, int nr, int index,
-				 unsigned int voltage)
+				 unsigned long voltage)
  {
  	int shift = 8 - REG_VOLTAGE_LIMIT_MSB_SHIFT[index - 1][nr];
  	int err;

Good catch.

Quoted 2 lines

Thanks!

Guenter

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