Skip to content

Commit

Permalink
gpio: Fix range check in of_gpio_simple_xlate()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Roland Stigge authored and Grant Likely committed Apr 10, 2012
1 parent 078dc65 commit 6270d83
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/of/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6270d83

Please sign in to comment.