]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
gpiolib: remove the GPIO device from the list when it's unregistered
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 2 Jan 2024 15:59:47 +0000 (16:59 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Thu, 4 Jan 2024 09:29:16 +0000 (10:29 +0100)
commit48e1b4d369cfe2729138a128afa6b8a55d093eaf
tree88e9fcc13fbf1362781e847c938bb56a28083174
parentc4f8457d17ce590c71aef53d75d49c313eb72cbc
gpiolib: remove the GPIO device from the list when it's unregistered

If we wait until the GPIO device's .release() callback gets invoked
before we remove it from the global device list, then we risk that
someone will look it up using gpio_device_find() between where we
dropped the last reference and before .release() is done taking a
reference again to an object that's being released.

The device must be removed when it's being unregistered - just like how
we remove it from the GPIO bus.

Fixes: ff2b13592299 ("gpio: make the gpiochip a real device")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib.c