pinctrl: bcm2835: Remove gpiochip on error
authorPhil Elwell <phil@raspberrypi.org>
Mon, 6 Jan 2020 16:04:30 +0000 (16:04 +0000)
committerPhil Elwell <pelwell@users.noreply.github.com>
Mon, 6 Jan 2020 16:30:00 +0000 (16:30 +0000)
A failure in gpiochip_irqchip_add leads to a leak of a gpiochip. Fix
the leak with the use of devm_gpiochip_add_data.

Fixes: 85ae9e512f43 ("pinctrl: bcm2835: switch to GPIOLIB_IRQCHIP")
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
drivers/pinctrl/bcm/pinctrl-bcm2835.c

index 455336c..92aa390 100644 (file)
@@ -1140,7 +1140,7 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
                raw_spin_lock_init(&pc->irq_lock[i]);
        }
 
-       err = gpiochip_add_data(&pc->gpio_chip, pc);
+       err = devm_gpiochip_add_data(dev, &pc->gpio_chip, pc);
        if (err) {
                dev_err(dev, "could not add GPIO chip\n");
                return err;