summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorLinus Walleij2016-06-18 10:56:43 +0200
committerLinus Walleij2016-06-18 10:56:43 +0200
commite2f608be640a126da50be605e1a81b988c9ac0d6 (patch)
treef9c73ed5cb33e94a9aedb9c280dcc7bdacd15d8f /drivers/gpio/gpiolib.c
parentgpiolib: avoid uninitialized data in gpio kfifo (diff)
downloadkernel-qcow2-linux-e2f608be640a126da50be605e1a81b988c9ac0d6.tar.gz
kernel-qcow2-linux-e2f608be640a126da50be605e1a81b988c9ac0d6.tar.xz
kernel-qcow2-linux-e2f608be640a126da50be605e1a81b988c9ac0d6.zip
gpio: make the iterator point to last handle
When initializing the GPIO handles, we use the iterator (i) to back off if something goes wrong. But since the iterator is also used after we pass the loop, we must decrement by one after exiting the loop so that we point at the last element in the array. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: Dan Carpenter <dan.carpenter@oracle.com> Cc: Walter Harms <wharms@bfs.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index c826844abdeb..b504364fd644 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -474,6 +474,8 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
dev_dbg(&gdev->dev, "registered chardev handle for line %d\n",
offset);
}
+ /* Let i point at the last handle */
+ i--;
lh->numdescs = handlereq.lines;
fd = anon_inode_getfd("gpio-linehandle",