linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: grant.likely@secretlab.ca (Grant Likely)
To: linux-arm-kernel@lists.infradead.org
Subject: GPIO range check in drivers/of/gpio.c
Date: Tue, 03 Apr 2012 09:37:58 -0600	[thread overview]
Message-ID: <20120403153759.037CA3E046E@localhost> (raw)
In-Reply-To: <4F7AB590.2090505@antcom.de>

On Tue, 03 Apr 2012 10:32:16 +0200, Roland Stigge <stigge@antcom.de> wrote:
> 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)

Yes, I think you're right.  Can you craft, test and post a patch?

Thanks,
g.

      reply	other threads:[~2012-04-03 15:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-03  8:32 GPIO range check in drivers/of/gpio.c Roland Stigge
2012-04-03 15:37 ` Grant Likely [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120403153759.037CA3E046E@localhost \
    --to=grant.likely@secretlab.ca \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).