2009-06-15 18:30:57

by Roel Kluin

[permalink] [raw]
Subject: [PATCH] regulator: add check index of wm8350->pmic.pdev[]

Ensure that reg is within the bounds of array wm8350->pmic.pdev[].

Signed-off-by: Roel Kluin <[email protected]>
---
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index 771eca1..c806259 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -1419,6 +1419,8 @@ int wm8350_register_regulator(struct wm8350 *wm8350, int reg,
{
struct platform_device *pdev;
int ret;
+ if (reg < 0 || reg >= NUM_WM8350_REGULATORS)
+ return -EINVAL;

if (wm8350->pmic.pdev[reg])
return -EBUSY;


2009-06-15 18:39:04

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] regulator: add check index of wm8350->pmic.pdev[]

On Mon, Jun 15, 2009 at 10:30:39PM +0200, Roel Kluin wrote:
> Ensure that reg is within the bounds of array wm8350->pmic.pdev[].
>
> Signed-off-by: Roel Kluin <[email protected]>

Acked-by: Mark Brown <[email protected]>

2009-06-16 09:15:45

by Liam Girdwood

[permalink] [raw]
Subject: Re: [PATCH] regulator: add check index of wm8350->pmic.pdev[]

On Mon, 2009-06-15 at 22:30 +0200, Roel Kluin wrote:
> Ensure that reg is within the bounds of array wm8350->pmic.pdev[].
>
> Signed-off-by: Roel Kluin <[email protected]>
> ---
> diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
> index 771eca1..c806259 100644
> --- a/drivers/regulator/wm8350-regulator.c
> +++ b/drivers/regulator/wm8350-regulator.c
> @@ -1419,6 +1419,8 @@ int wm8350_register_regulator(struct wm8350 *wm8350, int reg,
> {
> struct platform_device *pdev;
> int ret;
> + if (reg < 0 || reg >= NUM_WM8350_REGULATORS)
> + return -EINVAL;
>
> if (wm8350->pmic.pdev[reg])
> return -EBUSY;

Applied.

Thanks.

Liam