Skip to content

Commit

Permalink
gpiolib: Free the last requested descriptor
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: [email protected]
Fixes: ab3dbcf ("gpioib: do not free unrequested descriptors)
Reported-by: Jan Lorenzen <[email protected]>
Reported-by: Jim Paris <[email protected]>
Signed-off-by: Ricardo Ribalda Delgado <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
  • Loading branch information
ribalda authored and linusw committed Sep 18, 2018
1 parent 7876320 commit 19a4fbf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 19a4fbf

Please sign in to comment.