Skip to content

Commit 19a4fbf

Browse files
ribaldalinusw
authored andcommitted
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: ab3dbcf ("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>
1 parent 7876320 commit 19a4fbf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpio/gpiolib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
571571
if (ret)
572572
goto out_free_descs;
573573
lh->descs[i] = desc;
574-
count = i;
574+
count = i + 1;
575575

576576
if (lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW)
577577
set_bit(FLAG_ACTIVE_LOW, &desc->flags);

0 commit comments

Comments
 (0)