From: Herve Codina <herve.codina@bootlin.com>
To: Qingshuang Fu <fuqingshuang@kylinos.cn>
Cc: Thomas Gleixner <tglx@kernel.org>, Radu Rendec <radu@rendec.net>,
Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/3] irqdomain: Set IRQ_DOMAIN_FLAG_DESTROY_GC in __irq_domain_instantiate()
Date: Mon, 7 Sep 2026 08:46:53 +0200 [thread overview]
Message-ID: <20260907084653.490bfd62@bootlin.com> (raw)
In-Reply-To: <20260907024046.28845-2-fuqingshuang@kylinos.cn>
Hi Qingshuang,
On Mon, 7 Sep 2026 10:40:44 +0800
Qingshuang Fu <fuqingshuang@kylinos.cn> wrote:
> When a driver uses irq_domain_instantiate() with dgc_info to create
> generic irq chips, IRQ_DOMAIN_FLAG_DESTROY_GC is required so that
> irq_domain_remove() can clean up those generic chips.
>
> All existing in-tree callers manually set this flag today, but this
> pattern is error-prone. A future new caller forgetting to set the flag
> would leave generic chips allocated by irq_domain_alloc_generic_chips()
> leaked on domain removal.
>
> Set IRQ_DOMAIN_FLAG_DESTROY_GC right after
> irq_domain_alloc_generic_chips() succeeds inside
> __irq_domain_instantiate(). This makes automatic cleanup the default
> for all users that provide dgc_info via irq_domain_instantiate().
>
> This is the correct location for the flag because:
>
> - irq_domain_instantiate() is a high-level wrapper which internally
> allocates the generic chips, so it should also take responsibility
> for arranging their cleanup.
>
> - Setting the flag in irq_domain_alloc_generic_chips() would affect
> legacy callers like __irq_alloc_domain_generic_chips(), some of
> which have custom cleanup paths that manually free the generic
> chips (e.g. gpio-tb10x does kfree(domain->gc) before
> irq_domain_remove()), leading to use-after-free.
>
> Signed-off-by: Qingshuang Fu <fuqingshuang@kylinos.cn>
> ---
> kernel/irq/irqdomain.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
> index 57c819da30c2..4fdcb6df5306 100644
> --- a/kernel/irq/irqdomain.c
> +++ b/kernel/irq/irqdomain.c
> @@ -344,6 +344,7 @@ static struct irq_domain *__irq_domain_instantiate(const struct irq_domain_info
> err = irq_domain_alloc_generic_chips(domain, info->dgc_info);
> if (err)
> goto err_domain_free;
> + domain->flags |= IRQ_DOMAIN_FLAG_DESTROY_GC;
> }
>
> if (info->init) {
LGTM.
Reviewed-by: Herve Codina <herve.codina@bootlin.com>
Best regards,
Hervé
next prev parent reply other threads:[~2026-09-07 6:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 2:40 [PATCH v3 0/3] irqdomain: Auto-set IRQ_DOMAIN_FLAG_DESTROY_GC and remove redundant flag from drivers Qingshuang Fu
2026-09-07 2:40 ` [PATCH v3 1/3] irqdomain: Set IRQ_DOMAIN_FLAG_DESTROY_GC in __irq_domain_instantiate() Qingshuang Fu
2026-09-07 6:46 ` Herve Codina [this message]
2026-09-07 19:51 ` [tip: irq/drivers] " tip-bot2 for Qingshuang Fu
2026-09-07 2:40 ` [PATCH v3 2/3] irqchip/lan966x-oic: Drop redundant IRQ_DOMAIN_FLAG_DESTROY_GC Qingshuang Fu
2026-09-07 6:47 ` Herve Codina
2026-09-07 19:51 ` [tip: irq/drivers] " tip-bot2 for Qingshuang Fu
2026-09-07 2:40 ` [PATCH v3 3/3] soc/fsl/qe: qe_ports_ic: " Qingshuang Fu
2026-09-07 6:48 ` Herve Codina
2026-09-07 19:51 ` [tip: irq/drivers] " tip-bot2 for Qingshuang Fu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260907084653.490bfd62@bootlin.com \
--to=herve.codina@bootlin.com \
--cc=apw@canonical.com \
--cc=fuqingshuang@kylinos.cn \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=radu@rendec.net \
--cc=tglx@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®