lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200728001434.3thznd6a35ycb3f2@earth.universe>
Date:   Tue, 28 Jul 2020 02:14:34 +0200
From:   Sebastian Reichel <sre@...nel.org>
To:     trix@...hat.com
Cc:     anton.vorontsov@...aro.org, jtzhou@...vell.com,
        linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
        stable@...r.kernel.org
Subject: Re: [PATCH] power: supply: check if calc_soc succeeded in
 pm860x_init_battery

Hi,

On Sun, Jul 12, 2020 at 12:23:51PM -0700, trix@...hat.com wrote:
> From: Tom Rix <trix@...hat.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@...hat.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
> 

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ