Skip to contentSkip to conversation

power: bq27xxx_battery: signedness bug in bq27xxx_battery_read_health()

PATCH In review Dan Carpenter 3 participants 3 messages Sep 28, 2015 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: bq27xxx_battery: signedness bug in bq27xxx_battery_read_health()

We need flags to be signed for the error handling to work.

Fixes 74aab849f342 ('power: bq27xxx_battery: Cleanup health checking')
drivers/power/bq27xxx_battery.c +1 -1
index 473aa2f..994c78d 100644
@@ -691,7 +691,7 @@ static bool bq27xxx_battery_dead(struct bq27xxx_device_info *di, u16 flags)
  */
 static int bq27xxx_battery_read_health(struct bq27xxx_device_info *di)
 {
-	u16 flags;
+	int flags;
 
 	flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, false);
 	if (flags < 0) {
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Dan Carpenter

We need flags to be signed for the error handling to work.

Fixes 74aab849f342 ('power: bq27xxx_battery: Cleanup health checking')

This bug looks to have been added back in c91d36ea8116, either way the fix itself is correct so,

Quoted 2 lines
Quoted 14 lines
drivers/power/bq27xxx_battery.c +1 -1
index 473aa2f..994c78d 100644
@@ -691,7 +691,7 @@ static bool bq27xxx_battery_dead(struct bq27xxx_device_info *di, u16 flags)
   */
  static int bq27xxx_battery_read_health(struct bq27xxx_device_info *di)
  {
-	u16 flags;
+	int flags;
 
  	flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, false);
  	if (flags < 0) {
#2 lore raw
In reply to Dan Carpenter

Hi,

Quoted 4 lines · Dan Carpenter

We need flags to be signed for the error handling to work.

Fixes 74aab849f342 ('power: bq27xxx_battery: Cleanup health checking')

Thanks, Andrzej Hajda was slightly fast than you, so I merged his patch instead. I merged some of your patch description into his patch, though.

-- Sebastian