From: Sebastian Reichel <sre@kernel.org>
To: trix@redhat.com
Cc: anton.vorontsov@linaro.org, jtzhou@marvell.com,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] power: supply: check if calc_soc succeeded in pm860x_init_battery
Date: Tue, 28 Jul 2020 02:14:34 +0200 [thread overview]
Message-ID: <20200728001434.3thznd6a35ycb3f2@earth.universe> (raw)
In-Reply-To: <20200712192351.15428-1-trix@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1719 bytes --]
Hi,
On Sun, Jul 12, 2020 at 12:23:51PM -0700, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> 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>
> ---
Thanks, queued.
-- Sebastian
> drivers/power/supply/88pm860x_battery.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/supply/88pm860x_battery.c b/drivers/power/supply/88pm860x_battery.c
> index 1308f3a185f3..590da88a17a2 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;
> --
> 2.18.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2020-07-28 0:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-12 19:23 [PATCH] power: supply: check if calc_soc succeeded in pm860x_init_battery trix
2020-07-28 0:14 ` Sebastian Reichel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200728001434.3thznd6a35ycb3f2@earth.universe \
--to=sre@kernel.org \
--cc=anton.vorontsov@linaro.org \
--cc=jtzhou@marvell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=trix@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).