The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: tglx@kernel.org, jason@lakedaemon.net, lpieralisi@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 3/6] irqchip/gic-v3-its: Fix leak in its_vpe_irq_domain_alloc()
Date: Mon, 06 Jul 2026 09:36:52 +0100	[thread overview]
Message-ID: <86ldbopl97.wl-maz@kernel.org> (raw)
In-Reply-To: <e3252259-64e1-4bcb-8082-0bd501233747@huaweicloud.com>

On Fri, 03 Jul 2026 02:44:53 +0100,
Kemeng Shi <shikemeng@huaweicloud.com> wrote:
> 
> 在 2026/7/3 6:12:57, Marc Zyngier 写道:
> >> When its_irq_gic_domain_alloc() fails, the following
> >> its_vpe_irq_domain_free() skips calling its_vep_teardown() for the
> >> corresponding irq. Call its_vpe_teardown() when its_irq_gic_domain_alloc()
> >> is failedto 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 | 4 +++-
> >>  1 file changed, 3 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> >> index 3e4edcb64065..8968bedefdba 100644
> >> --- a/drivers/irqchip/irq-gic-v3-its.c
> >> +++ b/drivers/irqchip/irq-gic-v3-its.c
> >> @@ -4666,8 +4666,10 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq
> >>  			break;
> >>  		err = its_irq_gic_domain_alloc(domain, virq + i,
> >>  					       vm->vpes[i]->vpe_db_lpi);
> >> -		if (err)
> >> +		if (err) {
> >> +			its_vpe_teardown(vm->vpes[i]);
> >>  			break;
> >> +		}
> > There is already a spot for error handling in this function, we don't
> > need a second one.
> When its_irq_gic_domain_alloc() fails at index i, its_vpe_init(vpes[i])
> has already succeeded but the exisiting its_vpe_irq_domain_free(domain, virq, i)
> only tears down VPEs with index [0, i - 1], so its_vpe_teardown(vpes[i]) is still
> needed.
> So I guess you mean we can increase index when its_irq_gic_domain_alloc() fails to
> free the resource with existing error handling?
> Please correct me if I'm miss anything.

What I mean is this.

	M.
	
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index b57d81ad33a0a..4b1a3b497d7c4 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -4674,8 +4674,10 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq
 		irqd_set_resend_when_in_progress(irq_get_irq_data(virq + i));
 	}
 
-	if (err)
+	if (err) {
+		its_vpe_teardown(vm->vpes[i]);
 		its_vpe_irq_domain_free(domain, virq, i);
+	}
 
 	return err;
 }

-- 
Without deviation from the norm, progress is not possible.

  reply	other threads:[~2026-07-06  8:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02  3:30 [PATCH v4 0/6] Some Minor fixes and cleanups to irqchip/gic-v3-its Kemeng Shi
2026-07-02  3:30 ` [PATCH v4 1/6] irqchip/gic-v3-its: Fix memleak in its_probe_one() Kemeng Shi
2026-07-04 14:51   ` Radu Rendec
2026-07-02  3:30 ` [PATCH v4 2/6] irqchip/gic-v3-its: Fix its node leak in gic_acpi_parse_madt_its() Kemeng Shi
2026-07-04 15:08   ` Radu Rendec
2026-07-02  3:30 ` [PATCH v4 3/6] irqchip/gic-v3-its: Fix leak in its_vpe_irq_domain_alloc() Kemeng Shi
2026-07-02 22:12   ` Marc Zyngier
2026-07-03  1:44     ` Kemeng Shi
2026-07-06  8:36       ` Marc Zyngier [this message]
2026-07-02  3:30 ` [PATCH v4 4/6] irqchip/gic-v3-its: Add ITS address info in more error logs Kemeng Shi
2026-07-02 22:10   ` Marc Zyngier
2026-07-03  1:45     ` Kemeng Shi
2026-07-02  3:30 ` [PATCH v4 5/6] irqchip/gic-v3-its: Fix grammar and replace a bit number with its symbol Kemeng Shi
2026-07-04 15:37   ` Radu Rendec
2026-07-02  3:30 ` [PATCH v4 6/6] irqchip/gic-v3-its: Remove redundant check in its_vpe_db_proxy_unmap_locked() Kemeng Shi
2026-07-04 16:32   ` Radu Rendec
2026-07-06  8:31     ` Marc Zyngier

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=86ldbopl97.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=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