Skip to content

Commit c1c2a15

Browse files
Uwe Kleine-Königbrgl
authored andcommitted
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>
1 parent 9ca766e commit c1c2a15

1 file changed

Lines changed: 1 addition & 13 deletions

File tree

drivers/gpio/gpio-grgpio.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -434,25 +434,13 @@ static int grgpio_probe(struct platform_device *ofdev)
434434
static int grgpio_remove(struct platform_device *ofdev)
435435
{
436436
struct grgpio_priv *priv = platform_get_drvdata(ofdev);
437-
int i;
438-
int ret = 0;
439-
440-
if (priv->domain) {
441-
for (i = 0; i < GRGPIO_MAX_NGPIO; i++) {
442-
if (priv->uirqs[i].refcnt != 0) {
443-
ret = -EBUSY;
444-
goto out;
445-
}
446-
}
447-
}
448437

449438
gpiochip_remove(&priv->gc);
450439

451440
if (priv->domain)
452441
irq_domain_remove(priv->domain);
453442

454-
out:
455-
return ret;
443+
return 0;
456444
}
457445

458446
static const struct of_device_id grgpio_match[] = {

0 commit comments

Comments
 (0)