power: supply: check if calc_soc succeeded in pm860x_init_battery
authorTom Rix <trix@redhat.com>
Sun, 12 Jul 2020 19:23:51 +0000 (12:23 -0700)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Tue, 28 Jul 2020 00:13:21 +0000 (02:13 +0200)
commitccf193dee1f0fff55b556928591f7818bac1b3b1
treeb01cfbd7d52213e3cdc3ddf0828b346fb780140b
parent81bd45fc36e3d01db66c17fa5ed5f39a61e67477
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: a830d28b48bf ("power_supply: Enable battery-charger for 88pm860x")
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/88pm860x_battery.c