summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>2018-09-13 15:37:04 +0200
committerLinus Walleij <linus.walleij@linaro.org>2018-09-18 16:36:05 -0700
commit19a4fbffc94e41abaa2a623a25ce2641d69eccf0 (patch)
tree1d10c1d95a029af42fe32263a8306e143e845a3c
parent7876320f88802b22d4e2daf7eb027dd14175a0f8 (diff)
downloadop-kernel-dev-19a4fbffc94e41abaa2a623a25ce2641d69eccf0.zip
op-kernel-dev-19a4fbffc94e41abaa2a623a25ce2641d69eccf0.tar.gz
gpiolib: Free the last requested descriptor
The current code only frees N-1 gpios if an error occurs during gpiod_set_transitory, gpiod_direction_output or gpiod_direction_input. Leading to gpios that cannot be used by userspace nor other drivers. Cc: Timur Tabi <timur@codeaurora.org> Cc: stable@vger.kernel.org Fixes: ab3dbcf78f60f46d ("gpioib: do not free unrequested descriptors) Reported-by: Jan Lorenzen <jl@newtec.dk> Reported-by: Jim Paris <jim@jtan.com> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/gpio/gpiolib.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index e8f8a19..a57300c 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -571,7 +571,7 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
if (ret)
goto out_free_descs;
lh->descs[i] = desc;
- count = i;
+ count = i + 1;
if (lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW)
set_bit(FLAG_ACTIVE_LOW, &desc->flags);
OpenPOWER on IntegriCloud