gpio: Fix range check in of_gpio_simple_xlate()
authorRoland Stigge <stigge@antcom.de>
Wed, 4 Apr 2012 00:02:58 +0000 (02:02 +0200)
committerGrant Likely <grant.likely@secretlab.ca>
Tue, 10 Apr 2012 20:20:56 +0000 (14:20 -0600)
of_gpio_simple_xlate() has an off-by-one bug where it checks to see if
args[0] is > ngpio instead of >=.  args[0] must always be less than
ngpio because it is a zero-based enumeration.

Signed-off-by: Roland Stigge <stigge@antcom.de>
[grant.likely: beef up commit text]
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>

drivers/of/gpio.c

index bba8121..bf984b6 100644 (file)
@@ -140,7 +140,7 @@ int of_gpio_simple_xlate(struct gpio_chip *gc,
        if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells))
                return -EINVAL;
 
-       if (gpiospec->args[0] > gc->ngpio)
+       if (gpiospec->args[0] >= gc->ngpio)
                return -EINVAL;
 
        if (flags)