]> git.baikalelectronics.ru Git - kernel.git/commit
gpio: grgpio: Fix device removing
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tue, 21 Jun 2022 06:40:36 +0000 (08:40 +0200)
committerBartosz Golaszewski <brgl@bgdev.pl>
Thu, 23 Jun 2022 14:42:27 +0000 (16:42 +0200)
commit3a7e6caac76e4f7c71a5e44c0afe05e962556ea1
treec3f483f65ccb9dbe9204dfc13cc3f415f0486e9f
parent20df6a25e0edaa3e8f22a62323415df63d65558d
gpio: grgpio: Fix device removing

If a platform device's remove callback returns non-zero, the device core
emits a warning and still removes the device and calls the devm cleanup
callbacks.

So it's not save to not unregister the gpiochip because on the next request
to a GPIO the driver accesses kfree()'d memory. Also if an IRQ triggers,
the freed memory is accessed.

Instead rely on the GPIO framework to ensure that after gpiochip_remove()
all GPIOs are freed and so the corresponding IRQs are unmapped.

This is a preparation for making platform remove callbacks return void.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
drivers/gpio/gpio-grgpio.c