GPIO range check in drivers/of/gpio.c
Hi,
I'm wondering about a range check in drivers/of/gpio.c:144:
Quoted 11 lines
int of_gpio_simple_xlate(struct
gpio_chip*gc,
const structof_phandle_args*gpiospec, u32 *flags){ /* * We're discouraging gpio_cells < 2, since that way you'll have to * write your own xlate function (that will have to retrive the GPIO * number and the flags from a single gpio cell -- this is possible, * but not recommended). */ if (gc->of_gpio_n_cells < 2) { WARN_ON(1);
Quoted 8 lines
return -EINVAL; } if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells)) return -EINVAL; if (gpiospec->args[0] > gc->ngpio) return -EINVAL;
Shouldn't this be rather:
if (gpiospec->args[0] >= gc->ngpio)
?
Thanks in advance,
Roland
Quoted 21 lines · Roland Stigge
Hi,
I'm wondering about a range check in
drivers/of/gpio.c:144:Quoted 17 lines
int of_gpio_simple_xlate(struct
gpio_chip*gc,
const structof_phandle_args*gpiospec, u32 *flags){ /* * We're discouraging gpio_cells < 2, since that way you'll have to * write your own xlate function (that will have to retrive the GPIO * number and the flags from a single gpio cell -- this is possible, * but not recommended). */ if (gc->of_gpio_n_cells < 2) { WARN_ON(1); return -EINVAL; } if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells)) return -EINVAL;
Quoted 6 lines
Quoted 2 lines
if (gpiospec->args[0] > gc->ngpio) return -EINVAL;Shouldn't this be rather:
if (gpiospec->args[0] >= gc->ngpio)
Yes, I think you're right. Can you craft, test and post a patch?
Thanks,
g.