Skip to content

Commit ccf193d

Browse files
Tom Rixsre
authored andcommitted
power: supply: check if calc_soc succeeded in pm860x_init_battery
clang static analysis flags this error 88pm860x_battery.c:522:19: warning: Assigned value is garbage or undefined [core.uninitialized.Assign] info->start_soc = soc; ^ ~~~ soc is set by calling calc_soc. But calc_soc can return without setting soc. So check the return status and bail similarly to other checks in pm860x_init_battery and initialize soc to silence the warning. Fixes: a830d28 ("power_supply: Enable battery-charger for 88pm860x") Signed-off-by: Tom Rix <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 81bd45f commit ccf193d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/power/supply/88pm860x_battery.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ static void pm860x_init_battery(struct pm860x_battery_info *info)
433433
int ret;
434434
int data;
435435
int bat_remove;
436-
int soc;
436+
int soc = 0;
437437

438438
/* measure enable on GPADC1 */
439439
data = MEAS1_GP1;
@@ -496,7 +496,9 @@ static void pm860x_init_battery(struct pm860x_battery_info *info)
496496
}
497497
mutex_unlock(&info->lock);
498498

499-
calc_soc(info, OCV_MODE_ACTIVE, &soc);
499+
ret = calc_soc(info, OCV_MODE_ACTIVE, &soc);
500+
if (ret < 0)
501+
goto out;
500502

501503
data = pm860x_reg_read(info->i2c, PM8607_POWER_UP_LOG);
502504
bat_remove = data & BAT_WU_LOG;

0 commit comments

Comments
 (0)