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] [thread-next>] [day] [month] [year] [list]
Message-ID: <50066BF2.7050507@slimlogic.co.uk>
Date:	Wed, 18 Jul 2012 08:55:30 +0100
From:	Graeme Gregory <gg@...mlogic.co.uk>
To:	Axel Lin <axel.lin@...il.com>
CC:	Mark Brown <broonie@...nsource.wolfsonmicro.com>,
	linux-kernel@...r.kernel.org, Liam Girdwood <lrg@...com>
Subject: Re: [PATCH] regulator: palmas: Fix calculating selector in palmas_map_voltage_ldo

On 18/07/12 04:30, Axel Lin wrote:
> This patch fixes below issues when choosing selector:
>
> 1. Current code returns negative selector if min_uV < 900000 which is wrong.
>    For example, it is possible to satisfy the request with selector = 1 if
>    the requested min_uV is 850000.
Isnt this defending against bugs in the regulator core? I am normally
against repeating the same checks at multiple levels in a stack.
> 2. Current code may select a voltage lower than requested min_uV.
>    For example, if the requested min_uV is 945000, current code chooses
>    selector = 1 which is lower than requested min_uV.
>    DIV_ROUND_UP to avoid this case.
>
> Signed-off-by: Axel Lin <axel.lin@...il.com>
> ---
>  drivers/regulator/palmas-regulator.c |    9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
> index 17d19fb..0fcf355 100644
> --- a/drivers/regulator/palmas-regulator.c
> +++ b/drivers/regulator/palmas-regulator.c
> @@ -486,9 +486,12 @@ static int palmas_map_voltage_ldo(struct regulator_dev *rdev,
>  {
>  	int ret, voltage;
>  
> -	ret = ((min_uV - 900000) / 50000) + 1;
> -	if (ret < 0)
> -		return ret;
> +	if (min_uV == 0)
> +		return 0;
> +
> +	if (min_uV < 900000)
> +		min_uV = 900000;
> +	ret = DIV_ROUND_UP(min_uV - 900000, 50000) + 1;
>  
>  	/* Map back into a voltage to verify we're still in bounds */
>  	voltage = palmas_list_voltage_ldo(rdev, ret);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ