Skip to contentSkip to conversation

pinctrl: sunxi: Fix off-by-one for valid offset range checking

PATCH In review Axel Lin 2 participants 2 messages Aug 30, 2013

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 pinctrl: sunxi: Fix off-by-one for valid offset range checking

The valid offset range should be 0 ... chip->ngpio - 1.

---
 drivers/pinctrl/pinctrl-sunxi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/pinctrl-sunxi.c +1 -1
index b20df31..0ffd4c0 100644
@@ -529,7 +529,7 @@ static int sunxi_pinctrl_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
 	struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev);
 	struct sunxi_desc_function *desc;
 
-	if (offset > chip->ngpio)
+	if (offset >= chip->ngpio)
 		return -ENXIO;
 
 	desc = sunxi_pinctrl_desc_find_function_by_pin(pctl, offset, "irq");
Signature · 1 line
1.8.1.2