From: David Brownell <david-b@pacbell.net>
To: Trent Piepho <xyzzy@speakeasy.org>
Cc: linux-kernel@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] gpiolib: Fix off by one errors
Date: Tue, 20 May 2008 11:23:59 -0700 [thread overview]
Message-ID: <200805201124.00092.david-b@pacbell.net> (raw)
In-Reply-To: <1211306284-22469-1-git-send-email-xyzzy@speakeasy.org>
On Tuesday 20 May 2008, Trent Piepho wrote:
> The last gpio belonging to a chip is chip->base + chip->ngpios - 1. Some
> places in the code, but not all, forgot the critical minus one.
>
> Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
... should make it into 2.6.26-final, but this is evidently
not critical at this point or we'd have had complaints already!
> ---
> drivers/gpio/gpiolib.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 7f138c6..beaf6b3 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -127,7 +127,7 @@ int __init gpiochip_reserve(int start, int ngpio)
> unsigned long flags;
> int i;
>
> - if (!gpio_is_valid(start) || !gpio_is_valid(start + ngpio))
> + if (!gpio_is_valid(start) || !gpio_is_valid(start + ngpio - 1))
> return -EINVAL;
>
> spin_lock_irqsave(&gpio_lock, flags);
> @@ -170,7 +170,7 @@ int gpiochip_add(struct gpio_chip *chip)
> unsigned id;
> int base = chip->base;
>
> - if ((!gpio_is_valid(base) || !gpio_is_valid(base + chip->ngpio))
> + if ((!gpio_is_valid(base) || !gpio_is_valid(base + chip->ngpio - 1))
> && base >= 0) {
> status = -EINVAL;
> goto fail;
> @@ -207,7 +207,7 @@ fail:
> /* failures here can mean systems won't boot... */
> if (status)
> pr_err("gpiochip_add: gpios %d..%d (%s) not registered\n",
> - chip->base, chip->base + chip->ngpio,
> + chip->base, chip->base + chip->ngpio - 1,
> chip->label ? : "generic");
> return status;
> }
> --
> 1.5.4.1
>
prev parent reply other threads:[~2008-05-20 18:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-20 17:58 Trent Piepho
2008-05-20 18:23 ` David Brownell [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=200805201124.00092.david-b@pacbell.net \
--to=david-b@pacbell.net \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xyzzy@speakeasy.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
all inboxes | Powered by JetHome®