[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <F5EFB125-5C73-4DE5-8A4F-E0E92102D4F5@opensource.wolfsonmicro.com>
Date: Mon, 26 Jul 2010 00:06:15 -0700
From: Mark Brown <broonie@...nsource.wolfsonmicro.com>
To: Axel Lin <axel.lin@...il.com>
Cc: linux-kernel <linux-kernel@...r.kernel.org>,
Liam Girdwood <lrg@...mlogic.co.uk>,
Linus Walleij <linus.walleij@...ricsson.com>,
Mattias Wallin <mattias.wallin@...ricsson.com>
Subject: Re: [PATCH] ab3100: fix off-by-one value range checking for voltage selector
On 25 Jul 2010, at 22:35, Axel Lin <axel.lin@...il.com> wrote:
> The valid typ_voltages range should be 0..voltages_len-1.
>
> Signed-off-by: Axel Lin <axel.lin@...il.com>
Acked-by: Mark Brown <broonie@...nsource.wolfsonmicro.com>
It'd be nice to include a few extra words in the change log explaining that the reason for the limit is that it's an array index.
> ---
> drivers/regulator/ab3100.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c
> index 7b14a67..1179099 100644
> --- a/drivers/regulator/ab3100.c
> +++ b/drivers/regulator/ab3100.c
> @@ -286,7 +286,7 @@ static int ab3100_list_voltage_regulator(struct regulator_dev *reg,
> {
> struct ab3100_regulator *abreg = reg->reg_data;
>
> - if (selector > abreg->voltages_len)
> + if (selector >= abreg->voltages_len)
> return -EINVAL;
> return abreg->typ_voltages[selector];
> }
> @@ -318,7 +318,7 @@ static int ab3100_get_voltage_regulator(struct regulator_dev *reg)
> regval &= 0xE0;
> regval >>= 5;
>
> - if (regval > abreg->voltages_len) {
> + if (regval >= abreg->voltages_len) {
> dev_err(®->dev,
> "regulator register %02x contains an illegal voltage setting\n",
> abreg->regreg);
> --
> 1.5.4.3
>
>
>
--
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