diff options
| author | Tom Rix <trix@redhat.com> | 2020-07-12 12:23:51 -0700 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-08-19 08:16:16 +0200 |
| commit | 8d91c73c13f1a25855c55ecbb7058266b59b9994 (patch) | |
| tree | 8a34c88b2bc54332abcb3313eb7413be5105411f /drivers/power | |
| parent | b2b8438ed831ea7f709970e77c62bb5692a2ea97 (diff) | |
| download | linux-8d91c73c13f1a25855c55ecbb7058266b59b9994.tar.gz linux-8d91c73c13f1a25855c55ecbb7058266b59b9994.tar.bz2 linux-8d91c73c13f1a25855c55ecbb7058266b59b9994.zip | |
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>
Diffstat (limited to 'drivers/power')
| -rw-r--r-- | drivers/power/supply/88pm860x_battery.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/power/supply/88pm860x_battery.c b/drivers/power/supply/88pm860x_battery.c index 5ca047b3f58f..23e7d6447ae9 100644 --- a/drivers/power/supply/88pm860x_battery.c +++ b/drivers/power/supply/88pm860x_battery.c @@ -433,7 +433,7 @@ static void pm860x_init_battery(struct pm860x_battery_info *info) int ret; int data; int bat_remove; - int soc; + int soc = 0; /* measure enable on GPADC1 */ data = MEAS1_GP1; @@ -496,7 +496,9 @@ static void pm860x_init_battery(struct pm860x_battery_info *info) } mutex_unlock(&info->lock); - calc_soc(info, OCV_MODE_ACTIVE, &soc); + ret = calc_soc(info, OCV_MODE_ACTIVE, &soc); + if (ret < 0) + goto out; data = pm860x_reg_read(info->i2c, PM8607_POWER_UP_LOG); bat_remove = data & BAT_WU_LOG; |
