From f529a3742043a23da4f715c3664d5a822b1f970c Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Mon, 21 Jul 2008 17:08:14 +0000 Subject: surprise :p SVN-Revision: 11894 --- ...64-backport_gpiolib_fix_off_by_one_errors.patch | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 target/linux/generic-2.6/patches-2.6.25/964-backport_gpiolib_fix_off_by_one_errors.patch (limited to 'target/linux/generic-2.6/patches-2.6.25/964-backport_gpiolib_fix_off_by_one_errors.patch') 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 0000000000..715f9abbbf --- /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 +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 +Acked-by: David Brownell +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +--- + +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; + } -- cgit v1.2.3