linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regulator: Fix off-by-one value range checking for mc13xxx_regulator_get_voltage
@ 2011-05-18 12:56 Axel Lin
  2011-05-18 16:30 ` Mark Brown
  2011-05-21 11:54 ` Liam Girdwood
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2011-05-18 12:56 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yong Shen, Liam Girdwood, Mark Brown

We use val as array index,
thus the valid value rangae for val should be 0 .. n_voltages-1.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/mc13xxx-regulator-core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c
index 2bb5de1..bc27ab1 100644
--- a/drivers/regulator/mc13xxx-regulator-core.c
+++ b/drivers/regulator/mc13xxx-regulator-core.c
@@ -174,7 +174,7 @@ static int mc13xxx_regulator_get_voltage(struct regulator_dev *rdev)
 
 	dev_dbg(rdev_get_dev(rdev), "%s id: %d val: %d\n", __func__, id, val);
 
-	BUG_ON(val > mc13xxx_regulators[id].desc.n_voltages);
+	BUG_ON(val >= mc13xxx_regulators[id].desc.n_voltages);
 
 	return mc13xxx_regulators[id].voltages[val];
 }
-- 
1.7.1




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

* Re: [PATCH] regulator: Fix off-by-one value range checking for mc13xxx_regulator_get_voltage
  2011-05-18 12:56 [PATCH] regulator: Fix off-by-one value range checking for mc13xxx_regulator_get_voltage Axel Lin
@ 2011-05-18 16:30 ` Mark Brown
  2011-05-21 11:54 ` Liam Girdwood
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2011-05-18 16:30 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Yong Shen, Liam Girdwood

On Wed, May 18, 2011 at 08:56:45PM +0800, Axel Lin wrote:
> We use val as array index,
> thus the valid value rangae for val should be 0 .. n_voltages-1.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

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

* Re: [PATCH] regulator: Fix off-by-one value range checking for mc13xxx_regulator_get_voltage
  2011-05-18 12:56 [PATCH] regulator: Fix off-by-one value range checking for mc13xxx_regulator_get_voltage Axel Lin
  2011-05-18 16:30 ` Mark Brown
@ 2011-05-21 11:54 ` Liam Girdwood
  1 sibling, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2011-05-21 11:54 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Yong Shen, Mark Brown

On Wed, 2011-05-18 at 20:56 +0800, Axel Lin wrote:
> We use val as array index,
> thus the valid value rangae for val should be 0 .. n_voltages-1.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
>  drivers/regulator/mc13xxx-regulator-core.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c
> index 2bb5de1..bc27ab1 100644
> --- a/drivers/regulator/mc13xxx-regulator-core.c
> +++ b/drivers/regulator/mc13xxx-regulator-core.c
> @@ -174,7 +174,7 @@ static int mc13xxx_regulator_get_voltage(struct regulator_dev *rdev)
>  
>  	dev_dbg(rdev_get_dev(rdev), "%s id: %d val: %d\n", __func__, id, val);
>  
> -	BUG_ON(val > mc13xxx_regulators[id].desc.n_voltages);
> +	BUG_ON(val >= mc13xxx_regulators[id].desc.n_voltages);
>  
>  	return mc13xxx_regulators[id].voltages[val];
>  }

Applied

Thanks

Liam


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

end of thread, other threads:[~2011-05-21 11:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-18 12:56 [PATCH] regulator: Fix off-by-one value range checking for mc13xxx_regulator_get_voltage Axel Lin
2011-05-18 16:30 ` Mark Brown
2011-05-21 11:54 ` Liam Girdwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).