diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2008-07-21 17:08:14 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2008-07-21 17:08:14 +0000 |
commit | f529a3742043a23da4f715c3664d5a822b1f970c (patch) | |
tree | a4cdaee84e23765d98072df25883f365cbc0d66a /target/linux/generic-2.6/patches-2.6.25/964-backport_gpiolib_fix_off_by_one_errors.patch | |
parent | 3d9c4c9073deaf01d592d6940af21be81d92e88a (diff) | |
download | mtk-20170518-f529a3742043a23da4f715c3664d5a822b1f970c.zip mtk-20170518-f529a3742043a23da4f715c3664d5a822b1f970c.tar.gz mtk-20170518-f529a3742043a23da4f715c3664d5a822b1f970c.tar.bz2 |
surprise :p
SVN-Revision: 11894
Diffstat (limited to 'target/linux/generic-2.6/patches-2.6.25/964-backport_gpiolib_fix_off_by_one_errors.patch')
-rw-r--r-- | target/linux/generic-2.6/patches-2.6.25/964-backport_gpiolib_fix_off_by_one_errors.patch | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/target/linux/generic-2.6/patches-2.6.25/964-backport_gpiolib_fix_off_by_one_errors.patch b/target/linux/generic-2.6/patches-2.6.25/964-backport_gpiolib_fix_off_by_one_errors.patch new file mode 100644 index 0000000..715f9ab --- /dev/null +++ b/target/linux/generic-2.6/patches-2.6.25/964-backport_gpiolib_fix_off_by_one_errors.patch @@ -0,0 +1,48 @@ +From: Trent Piepho <xyzzy@speakeasy.org> +Date: Fri, 23 May 2008 20:04:44 +0000 (-0700) +Subject: gpiolib: fix off by one errors +X-Git-Tag: v2.6.26-rc4~31 +X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=bff5fda972dc23bd1806a47c2098ae173585d013 + +gpiolib: fix off by one errors + +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> +Signed-off-by: Andrew Morton <akpm@linux-foundation.org> +Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> +--- + +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; + } |