Re: [PATCH] gpio: omap: Fix error path on chip init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 01/02/2018 04:23 AM, Linus Walleij wrote:
The error path was leaking a gpio_chip at one point.

Cc: Johan Hovold <johan@xxxxxxxxxx>
Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>


Sry, but this seems not in sync with gpio-next [1]

https://patchwork.kernel.org/patch/10060049/


---
  drivers/gpio/gpio-omap.c | 13 +++++++++----
  1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index e136d666f1e5..d83e8624964a 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1104,7 +1104,8 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
  					-1, 0, bank->width, 0);
  	if (irq_base < 0) {
  		dev_err(bank->chip.parent, "Couldn't allocate IRQ numbers\n");
-		return -ENODEV;
+		ret = -ENODEV;
+		goto err_remove_chip;
  	}
  #endif
@@ -1122,8 +1123,8 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
  	if (ret) {
  		dev_err(bank->chip.parent,
  			"Couldn't add irqchip to gpiochip %d\n", ret);
-		gpiochip_remove(&bank->chip);
-		return -ENODEV;
+		ret = -ENODEV;
+		goto err_remove_chip;
  	}
gpiochip_set_chained_irqchip(&bank->chip, irqc, bank->irq, NULL);
@@ -1132,8 +1133,12 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
  			       omap_gpio_irq_handler,
  			       0, dev_name(bank->chip.parent), bank);
  	if (ret)
-		gpiochip_remove(&bank->chip);
+		goto err_remove_chip;
+ return 0;
+
+err_remove_chip:
+	gpiochip_remove(&bank->chip);
  	return ret;
  }

--
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux