From: Marc Zyngier <maz@kernel.org>
To: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: tglx@kernel.org, jason@lakedaemon.net, lpieralisi@kernel.org,
radu@rendec.net, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 3/4] irqchip/gic-v3-its: Fix leak in its_vpe_irq_domain_alloc()
Date: Mon, 20 Jul 2026 09:50:00 +0100 [thread overview]
Message-ID: <86a4rmf3k7.wl-maz@kernel.org> (raw)
In-Reply-To: <20260720071215.50705-4-shikemeng@huaweicloud.com>
On Mon, 20 Jul 2026 08:12:14 +0100,
Kemeng Shi <shikemeng@huaweicloud.com> wrote:
>
> When its_irq_gic_domain_alloc() fails, the following
> its_vpe_irq_domain_free() skips calling its_vep_teardown() for the
> corresponding irq. Try its_vpe_teardown() in error handling to avoid
> the leak issue.
>
> Fixes: 7d75bbb4bc1ad ("irqchip/gic-v3-its: Add VPE irq domain allocation/teardown")
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
> drivers/irqchip/irq-gic-v3-its.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> index 3e4edcb64065..5dc91862fc15 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -4594,9 +4594,11 @@ static int its_vpe_init(struct its_vpe *vpe)
>
> static void its_vpe_teardown(struct its_vpe *vpe)
> {
> - its_vpe_db_proxy_unmap(vpe);
> - its_vpe_id_free(vpe->vpe_id);
> - its_free_pending_table(vpe->vpt_page);
> + if (vpe->vpt_page != NULL) {
> + its_vpe_db_proxy_unmap(vpe);
> + its_vpe_id_free(vpe->vpe_id);
> + its_free_pending_table(vpe->vpt_page);
> + }
Please keep the diff minimal by doing an early return. This also
deserves a comment, because this is not completely obvious:
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 6f5811aae59c1..38032067135b6 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -4592,6 +4592,13 @@ static int its_vpe_init(struct its_vpe *vpe)
static void its_vpe_teardown(struct its_vpe *vpe)
{
+ /*
+ * If vpt_page is NULL, then its_vpe_init() has failed, and
+ * there is nothing to do as no resource has been allocated.
+ */
+ if (!vpe->vpt_page)
+ return;
+
its_vpe_db_proxy_unmap(vpe);
its_vpe_id_free(vpe->vpe_id);
its_free_pending_table(vpe->vpt_page);
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2026-07-20 9:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 7:12 [PATCH v5 0/4] Some Minor fixes and cleanups to irqchip/gic-v3-its Kemeng Shi
2026-07-20 7:12 ` [PATCH v5 1/4] irqchip/gic-v3-its: Fix memleak in its_probe_one() Kemeng Shi
2026-07-20 7:12 ` [PATCH v5 2/4] irqchip/gic-v3-its: Fix its node leak in gic_acpi_parse_madt_its() Kemeng Shi
2026-07-20 7:12 ` [PATCH v5 3/4] irqchip/gic-v3-its: Fix leak in its_vpe_irq_domain_alloc() Kemeng Shi
2026-07-20 8:50 ` Marc Zyngier [this message]
2026-07-21 1:28 ` Kemeng Shi
2026-07-20 7:12 ` [PATCH v5 4/4] irqchip/gic-v3-its: Fix grammar and replace a bit number with its symbol Kemeng Shi
2026-07-21 0:58 ` Radu Rendec
2026-07-21 2:26 ` Kemeng Shi
2026-07-20 18:46 ` [PATCH v5 0/4] Some Minor fixes and cleanups to irqchip/gic-v3-its Thomas Gleixner
2026-07-21 2:25 ` Kemeng Shi
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=86a4rmf3k7.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=jason@lakedaemon.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=radu@rendec.net \
--cc=shikemeng@huaweicloud.com \
--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