All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: regmap: free the irqchip if adding the irq domain fails
@ 2026-11-03  4:47 ` Long Zhao via B4 Relay
  0 siblings, 0 replies; 5+ messages in thread
From: Long Zhao @ 2026-11-03  4:47 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Michael Walle, linux-gpio, Long Zhao, Long Zhao

gpio_regmap_register() creates a regmap irqchip and then calls
gpiochip_irqchip_add_domain(). If that call fails, the error path
only removes the gpiochip, so the irqchip and its domain leak.

Free the irqchip there when this function allocated it. An external
irq domain is not affected: irq_chip_data stays NULL and the caller
owns that domain.

Fixes: 553b75d4bfe9 ("gpio: regmap: Allow to allocate regmap-irq device")
Cc: Michael Walle <mwalle@kernel.org>
Signed-off-by: Long Zhao <longzhao@ambarella.com>
---
 drivers/gpio/gpio-regmap.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index 51b4d69b8740..7689357e6077 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -418,6 +418,11 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
 
 err_remove_gpiochip:
 	gpiochip_remove(chip);
+
+#ifdef CONFIG_REGMAP_IRQ
+	if (gpio->irq_chip_data)
+		regmap_del_irq_chip(gpio->regmap_irq_line, gpio->irq_chip_data);
+#endif
 err_free_bitmap_output:
 	bitmap_free(gpio->fixed_direction_output);
 err_free_bitmap_dirmask:

---
base-commit: 34cf6dafc47441dfb6b356a095b89c3585a93714
change-id: 20261103-gpio-regmap-irqchip-leak-095fdd8fd4fc

Best regards,
--  
Long Zhao <longzhao@ambarella.com>


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-05 12:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-03  4:47 [PATCH] gpio: regmap: free the irqchip if adding the irq domain fails Long Zhao
2026-11-03  4:47 ` Long Zhao via B4 Relay
2026-11-05  8:38 ` Linus Walleij
2026-11-05  8:59 ` Michael Walle
2026-11-05 12:36 ` Bartosz Golaszewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.