Commit fdc7a9f8 authored by Axel Lin's avatar Axel Lin Committed by Linus Walleij

gpio: lpc32xx: Fix off-by-one valid range checking for bank

The valid bank should be 0 ... ARRAY_SIZE(lpc32xx_gpiochip) - 1.
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 97ddb1c8
...@@ -533,7 +533,7 @@ static int lpc32xx_of_xlate(struct gpio_chip *gc, ...@@ -533,7 +533,7 @@ static int lpc32xx_of_xlate(struct gpio_chip *gc,
{ {
/* Is this the correct bank? */ /* Is this the correct bank? */
u32 bank = gpiospec->args[0]; u32 bank = gpiospec->args[0];
if ((bank > ARRAY_SIZE(lpc32xx_gpiochip) || if ((bank >= ARRAY_SIZE(lpc32xx_gpiochip) ||
(gc != &lpc32xx_gpiochip[bank].chip))) (gc != &lpc32xx_gpiochip[bank].chip)))
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment