Skip to contentSkip to conversation

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

PATCH In review Axel Lin 2 participants 2 messages Apr 7, 2013 – Apr 10, 2013

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

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

The valid bank should be 0 ... ARRAY_SIZE(lpc32xx_gpiochip) - 1.

---
 drivers/gpio/gpio-lpc32xx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-lpc32xx.c +1 -1
index 36d7dee..dda6a75 100644
@@ -533,7 +533,7 @@ static int lpc32xx_of_xlate(struct gpio_chip *gc,
 {
 	/* Is this the correct bank? */
 	u32 bank = gpiospec->args[0];
-	if ((bank > ARRAY_SIZE(lpc32xx_gpiochip) ||
+	if ((bank >= ARRAY_SIZE(lpc32xx_gpiochip) ||
 	    (gc != &lpc32xx_gpiochip[bank].chip)))
 		return -EINVAL;
 
Signature · 1 line
1.7.10.4