public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH resend] ab3100: fix off-by-one value range checking for voltage selector
@ 2010-07-26  7:34 Axel Lin
  2010-07-26  9:02 ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Axel Lin @ 2010-07-26  7:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Liam Girdwood, Mark Brown, Linus Walleij, Mattias Wallin

We use voltage selector as an array index for typ_voltages.
Thus the valid range for voltage selector should be 0..voltages_len-1.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
Simply update the changelog 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(&reg->dev,
 			"regulator register %02x contains an illegal voltage setting\n",
 			abreg->regreg);
-- 
1.5.4.3




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH resend] ab3100: fix off-by-one value range checking for  voltage selector
  2010-07-26  7:34 [PATCH resend] ab3100: fix off-by-one value range checking for voltage selector Axel Lin
@ 2010-07-26  9:02 ` Linus Walleij
  2010-07-27 10:35   ` Liam Girdwood
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2010-07-26  9:02 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Liam Girdwood, Mark Brown, Mattias Wallin

2010/7/26 Axel Lin <axel.lin@gmail.com>:

> We use voltage selector as an array index for typ_voltages.
> Thus the valid range for voltage selector should be 0..voltages_len-1.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Acked-by: Linus Walleij <linus.walleij@stericsson.com>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH resend] ab3100: fix off-by-one value range checking for voltage selector
  2010-07-26  9:02 ` Linus Walleij
@ 2010-07-27 10:35   ` Liam Girdwood
  0 siblings, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2010-07-27 10:35 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Axel Lin, linux-kernel, Mark Brown, Mattias Wallin

On Mon, 2010-07-26 at 11:02 +0200, Linus Walleij wrote:
> 2010/7/26 Axel Lin <axel.lin@gmail.com>:
> 
> > We use voltage selector as an array index for typ_voltages.
> > Thus the valid range for voltage selector should be 0..voltages_len-1.
> >
> > Signed-off-by: Axel Lin <axel.lin@gmail.com>
> > Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> 
> Acked-by: Linus Walleij <linus.walleij@stericsson.com>

Applied.

Thanks

Liam
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-07-27 10:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-26  7:34 [PATCH resend] ab3100: fix off-by-one value range checking for voltage selector Axel Lin
2010-07-26  9:02 ` Linus Walleij
2010-07-27 10:35   ` Liam Girdwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox