* [PATCH] gpio: regmap: free the irqchip if adding the irq domain fails
@ 2026-11-03 4:47 Long Zhao via B4 Relay
2026-11-05 8:38 ` Linus Walleij
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Long Zhao via B4 Relay @ 2026-11-03 4:47 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Linus Walleij, Michael Walle, linux-gpio, Long Zhao, Long Zhao
From: Long Zhao <longzhao@ambarella.com>
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] 4+ messages in thread
* Re: [PATCH] gpio: regmap: free the irqchip if adding the irq domain fails
2026-11-03 4:47 [PATCH] gpio: regmap: free the irqchip if adding the irq domain fails 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
2 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2026-11-05 8:38 UTC (permalink / raw)
To: longzhao; +Cc: Bartosz Golaszewski, Michael Walle, linux-gpio, Long Zhao
On Tue, Nov 3, 2026 at 5:47 AM Long Zhao via B4 Relay
<devnull+longzhao.ambarella.com@kernel.org> wrote:
> From: Long Zhao <longzhao@ambarella.com>
>
> 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>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: regmap: free the irqchip if adding the irq domain fails
2026-11-03 4:47 [PATCH] gpio: regmap: free the irqchip if adding the irq domain fails 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
2 siblings, 0 replies; 4+ messages in thread
From: Michael Walle @ 2026-11-05 8:59 UTC (permalink / raw)
To: longzhao, Bartosz Golaszewski; +Cc: Linus Walleij, linux-gpio, Long Zhao
[-- Attachment #1: Type: text/plain, Size: 704 bytes --]
On Tue Nov 3, 2026 at 5:47 AM CET, Long Zhao via B4 Relay wrote:
> From: Long Zhao <longzhao@ambarella.com>
>
> 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>
Reviewed-by: Michael Walle <mwalle@kernel.org>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 297 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: regmap: free the irqchip if adding the irq domain fails
2026-11-03 4:47 [PATCH] gpio: regmap: free the irqchip if adding the irq domain fails 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
2 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2026-11-05 12:36 UTC (permalink / raw)
To: Bartosz Golaszewski, Long Zhao
Cc: Bartosz Golaszewski, Linus Walleij, Michael Walle, linux-gpio,
Long Zhao
On Tue, 03 Nov 2026 12:47:17 +0800, Long Zhao wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] gpio: regmap: free the irqchip if adding the irq domain fails
https://git.kernel.org/brgl/c/80415a6ff295b03dab98ef55598c72be66945d82
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-05 12:36 UTC | newest]
Thread overview: 4+ 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 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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox