Skip to content

Commit 2526dff

Browse files
author
Bartosz Golaszewski
committed
gpio: remove GPIO device from the list unconditionally in error path
Since commit 48e1b4d ("gpiolib: remove the GPIO device from the list when it's unregistered") we remove the GPIO device entry from the global list (used to order devices by their GPIO ranges) when unregistering the chip, not when releasing the device. It will not happen when the last reference is put anymore. This means, we need to remove it in error path in gpiochip_add_data_with_key() unconditionally, without checking if the device's .release() callback is set. Fixes: 48e1b4d ("gpiolib: remove the GPIO device from the list when it's unregistered") Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent 54be6c6 commit 2526dff

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/gpio/gpiolib.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,15 +1005,15 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
10051005
err_free_gpiochip_mask:
10061006
gpiochip_remove_pin_ranges(gc);
10071007
gpiochip_free_valid_mask(gc);
1008+
err_remove_from_list:
1009+
spin_lock_irqsave(&gpio_lock, flags);
1010+
list_del(&gdev->list);
1011+
spin_unlock_irqrestore(&gpio_lock, flags);
10081012
if (gdev->dev.release) {
10091013
/* release() has been registered by gpiochip_setup_dev() */
10101014
gpio_device_put(gdev);
10111015
goto err_print_message;
10121016
}
1013-
err_remove_from_list:
1014-
spin_lock_irqsave(&gpio_lock, flags);
1015-
list_del(&gdev->list);
1016-
spin_unlock_irqrestore(&gpio_lock, flags);
10171017
err_free_label:
10181018
kfree_const(gdev->label);
10191019
err_free_descs:

0 commit comments

Comments
 (0)