From: Marc Zyngier <maz@kernel.org>
To: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: tglx@kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/6] irqchip/gic-v3-its: Fix LPI range leak and refactor error handler in its_lpi_alloc()
Date: Wed, 17 Jun 2026 13:09:51 +0100 [thread overview]
Message-ID: <86y0gds700.wl-maz@kernel.org> (raw)
In-Reply-To: <cda86396-afe1-4bc9-97c2-0e7a3c739217@huaweicloud.com>
On Tue, 16 Jun 2026 02:31:22 +0100,
Kemeng Shi <shikemeng@huaweicloud.com> wrote:
>
> 在 2026/6/15 16:52:56, Marc Zyngier 写道:
> > On Mon, 15 Jun 2026 04:29:05 +0100,
> > Kemeng Shi <shikemeng@huaweicloud.com> wrote:
> >>
> >> Fix the LIP range leak when bitmap_zalloc() failed. Besides refactor
> >
> > Typo.
> >
> >> error handling code to make it a little simpler.
> >
> > No. Please don't mix fixes and (totally pointless) refactoring.
> OK, I will only keep fix in this patch.>
> >>
> >> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> >> ---
> >> drivers/irqchip/irq-gic-v3-its.c | 21 +++++++++------------
> >> 1 file changed, 9 insertions(+), 12 deletions(-)
> >>
> >> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> >> index 291d7668cc8d..2b7b546c43c8 100644
> >> --- a/drivers/irqchip/irq-gic-v3-its.c
> >> +++ b/drivers/irqchip/irq-gic-v3-its.c
> >> @@ -2217,10 +2217,9 @@ static int __init its_lpi_init(u32 id_bits)
> >> static unsigned long *its_lpi_alloc(int nr_irqs, u32 *base, int *nr_ids)
> >> {
> >> unsigned long *bitmap = NULL;
> >> - int err = 0;
> >>
> >> do {
> >> - err = alloc_lpi_range(nr_irqs, base);
> >> + int err = alloc_lpi_range(nr_irqs, base);
> >> if (!err)
> >> break;
> >>
> >> @@ -2228,22 +2227,20 @@ static unsigned long *its_lpi_alloc(int nr_irqs, u32 *base, int *nr_ids)
> >> } while (nr_irqs > 0);
> >>
> >> if (!nr_irqs)
> >> - err = -ENOSPC;
> >> -
> >> - if (err)
> >> - goto out;
> >> + goto err_out;
> >>
> >> bitmap = bitmap_zalloc(nr_irqs, GFP_ATOMIC);
> >> if (!bitmap)
> >> - goto out;
> >> + goto err_free_lpi;
> >>
> >> *nr_ids = nr_irqs;
> >> -
> >> -out:
> >> - if (!bitmap)
> >> - *base = *nr_ids = 0;
> >> -
> >> return bitmap;
> >> +
> >> +err_free_lpi:
> >> + free_lpi_range(*base, nr_irqs);
> >> +err_out:
> >> + *base = *nr_ids = 0;
> >> + return NULL;
> >> }
> >>
> >> static void its_lpi_free(unsigned long *bitmap, u32 base, u32 nr_ids)
> >
> > Honestly, I question the validity of handling errors this way. You are
> > already unable to allocate a per-device bitmap. And yet you are
> > calling free_lpi_range(), which has the interesting property of
> > *allocating* memory. Which you don't have. Oh wait...
> You are right. I'm considering use xarray to track the lpi range or
> modify free_lpi_range to try merge first before memory allocation.
> What would you recommend?
My personal take on this is that leaking a few LPIs is not a big deal,
given how many we have. You are trying to optimise for an error case
that never happens, and I really don't want to add more complexity to
this.
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2026-06-17 12:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-15 3:29 [PATCH 0/6] Some random fixes and cleanups to irqchip/gic-v3-its Kemeng Shi
2026-06-15 3:29 ` [PATCH 1/6] irqchip/gic-v3-its: Fix LPI range leak and refactor error handler in its_lpi_alloc() Kemeng Shi
2026-06-15 8:52 ` Marc Zyngier
2026-06-16 1:31 ` Kemeng Shi
2026-06-17 12:09 ` Marc Zyngier [this message]
2026-06-15 3:29 ` [PATCH 2/6] irqchip/gic-v3-its: Fix memleak in its_probe_one() Kemeng Shi
2026-06-15 8:59 ` Marc Zyngier
2026-06-16 1:39 ` Kemeng Shi
2026-06-17 12:07 ` Marc Zyngier
2026-06-15 3:29 ` [PATCH 3/6] irqchip/gic-v3-its: Fix its node leak in gic_acpi_parse_madt_its() Kemeng Shi
2026-06-15 3:29 ` [PATCH 4/6] irqchip/gic-v3-its: Add ITS address info in more error logs Kemeng Shi
2026-06-15 9:01 ` Marc Zyngier
2026-06-16 1:48 ` Kemeng Shi
2026-06-15 3:29 ` [PATCH 5/6] irqchip/gic-v3-its: fix typo in comments Kemeng Shi
2026-06-15 9:03 ` Marc Zyngier
2026-06-16 1:49 ` Kemeng Shi
2026-06-15 3:29 ` [PATCH 6/6] irqchip/gic-v3-its: some minor cleanups Kemeng Shi
2026-06-15 9:14 ` Marc Zyngier
2026-06-16 1:50 ` 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=86y0gds700.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.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