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: <20180711100418.p2t4mfvgyjbzrxwy@earth.universe>
Date:   Wed, 11 Jul 2018 12:04:18 +0200
From:   Sebastian Reichel <sre@...nel.org>
To:     Dan Carpenter <dan.carpenter@...cle.com>
Cc:     Stefan Popa <stefan.popa@...log.com>, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] power: supply: adp5061: Fix a couple off by ones

Hi,

On Wed, Jul 11, 2018 at 10:58:13AM +0300, Dan Carpenter wrote:
> We end up reading one element beyond the end of the adp5061_vmax[] array
> here.
> 
> Fixes: fe8e81b7e899 ("adp5061: New driver for ADP5061 I2C battery charger")
> Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>

Thanks, queued.

-- Sebastian

> diff --git a/drivers/power/supply/adp5061.c b/drivers/power/supply/adp5061.c
> index c00a02ef7424..939fd3d8fb1a 100644
> --- a/drivers/power/supply/adp5061.c
> +++ b/drivers/power/supply/adp5061.c
> @@ -266,8 +266,8 @@ static int adp5061_get_max_voltage(struct adp5061_state *st,
>  		return ret;
>  
>  	regval = ((regval & ADP5061_TERM_SET_VTRM_MSK) >> 2) - 0x0F;
> -	if (regval > ARRAY_SIZE(adp5061_vmax))
> -		regval = ARRAY_SIZE(adp5061_vmax);
> +	if (regval >= ARRAY_SIZE(adp5061_vmax))
> +		regval = ARRAY_SIZE(adp5061_vmax) - 1;
>  
>  	val->intval = adp5061_vmax[regval] * 1000;
>  
> @@ -344,8 +344,8 @@ static int adp5061_get_const_chg_current(struct adp5061_state *st,
>  		return ret;
>  
>  	regval = ((regval & ADP5061_CHG_CURR_ICHG_MSK) >> 2);
> -	if (regval > ARRAY_SIZE(adp5061_const_ichg))
> -		regval = ARRAY_SIZE(adp5061_const_ichg);
> +	if (regval >= ARRAY_SIZE(adp5061_const_ichg))
> +		regval = ARRAY_SIZE(adp5061_const_ichg) - 1;
>  
>  	val->intval = adp5061_const_ichg[regval] * 1000;
>  

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