From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Axel Lin <axel.lin@gmail.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Liam Girdwood <lrg@slimlogic.co.uk>,
Linus Walleij <linus.walleij@stericsson.com>,
Mattias Wallin <mattias.wallin@stericsson.com>
Subject: Re: [PATCH] ab3100: fix off-by-one value range checking for voltage selector
Date: Mon, 26 Jul 2010 00:06:15 -0700 [thread overview]
Message-ID: <F5EFB125-5C73-4DE5-8A4F-E0E92102D4F5@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1280122549.20830.1.camel@mola> (sfid-20100726_063529_143771_2699E6C4)
On 25 Jul 2010, at 22:35, Axel Lin <axel.lin@gmail.com> wrote:
> The valid typ_voltages range should be 0..voltages_len-1.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.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
>
>
>
prev parent reply other threads:[~2010-07-26 7:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-26 5:35 Axel Lin
2010-07-26 7:06 ` Mark Brown [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=F5EFB125-5C73-4DE5-8A4F-E0E92102D4F5@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=axel.lin@gmail.com \
--cc=linus.walleij@stericsson.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@slimlogic.co.uk \
--cc=mattias.wallin@stericsson.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
all inboxes | Powered by JetHome®