]> git.ipfire.org Git - thirdparty/kernel/stable.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 08:53:02 +0000 (10:53 +0200)
commit2bb65635094df097893a9b542552853bd29a6be9
treec75f5aa97eae0ed2c263334208659c9bd1ef3b40
parent23e854676593fa65adf1f103aec84e7a03a396e1
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/88pm860x_battery.c