linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* GPIO range check in drivers/of/gpio.c
@ 2012-04-03  8:32 Roland Stigge
  2012-04-03 15:37 ` Grant Likely
  0 siblings, 1 reply; 2+ messages in thread
From: Roland Stigge @ 2012-04-03  8:32 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

I'm wondering about a range check in drivers/of/gpio.c:144:

> int of_gpio_simple_xlate(struct gpio_chip *gc,
>			 const struct of_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;
>
>	if (gpiospec->args[0] > gc->ngpio)
>		return -EINVAL;

Shouldn't this be rather:

	if (gpiospec->args[0] >= gc->ngpio)

?

Thanks in advance,

Roland

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-03 15:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-03  8:32 GPIO range check in drivers/of/gpio.c Roland Stigge
2012-04-03 15:37 ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).