Commit 58bddf7b authored by Tom Rix's avatar Tom Rix Committed by Kelsey Skunberg

power: supply: check if calc_soc succeeded in pm860x_init_battery

BugLink: https://bugs.launchpad.net/bugs/1892822

[ Upstream commit ccf193de ]

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: a830d28b ("power_supply: Enable battery-charger for 88pm860x")
Signed-off-by: default avatarTom Rix <trix@redhat.com>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarIan May <ian.may@canonical.com>
Signed-off-by: default avatarKelsey Skunberg <kelsey.skunberg@canonical.com>
parent 7c2fd7ba
......@@ -436,7 +436,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;
......@@ -499,7 +499,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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment