]> git.ipfire.org Git - people/arne_f/kernel.git/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 07:48:11 +0000 (09:48 +0200)
commitca869971a904aa67813a1b04624df4cd83e06196
treecd2f825dfd1b3fb97bd324a457fc34b761429300
parent75f8b5a67b62b40d6308f3f2998de2cfa264f212
power: supply: check if calc_soc succeeded in pm860x_init_battery

[ Upstream commit ccf193dee1f0fff55b556928591f7818bac1b3b1 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/power/supply/88pm860x_battery.c