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 2/6] irqchip/gic-v3-its: Fix memleak in its_probe_one()
Date: Wed, 17 Jun 2026 13:07:54 +0100 [thread overview]
Message-ID: <86zf0ts739.wl-maz@kernel.org> (raw)
In-Reply-To: <bf396073-9a23-4602-ad64-ac3f38f2df65@huaweicloud.com>
On Tue, 16 Jun 2026 02:39:10 +0100,
Kemeng Shi <shikemeng@huaweicloud.com> wrote:
>
> 在 2026/6/15 16:59:14, Marc Zyngier 写道:
> > On Mon, 15 Jun 2026 04:29:06 +0100,
> > Kemeng Shi <shikemeng@huaweicloud.com> wrote:
> >>
> >> Fix collection leak when its_init_domain() failed in its_probe_one().
> >>
> >> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> >> ---
> >> drivers/irqchip/irq-gic-v3-its.c | 10 +++++++++-
> >> 1 file changed, 9 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> >> index 2b7b546c43c8..df26ddc97ae2 100644
> >> --- a/drivers/irqchip/irq-gic-v3-its.c
> >> +++ b/drivers/irqchip/irq-gic-v3-its.c
> >> @@ -3032,6 +3032,12 @@ static int its_alloc_collections(struct its_node *its)
> >> return 0;
> >> }
> >>
> >> +static void its_free_collections(struct its_node *its)
> >> +{
> >> + kfree(its->collections);
> >> + its->collections = NULL;
> >> +}
> >
> > Why do we need an extra helper for something that has a single calling
> > spot? Why is it important to set collections to NULL, given that we're
> > about to free the structure without even looking further?
> >
> The extra helper is added for symmetry with its_alloc_collections(), keeping
> allocation/deallocation logic paired.
But there is zero logic here. None. it is a call to kfree(), just
that, and we don't need any additional abstraction.
> In this way, we need to only modified
> allocation/deallocation function if more member is added for collections.
Well, when we get there, we can always add an abstraction.
> Setting collections to NULL is a personal habit to quickly catch use-after-free
> of collections. Could drop this which is not that import.
I don't see the point of doing that.
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2026-06-17 12:08 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
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 [this message]
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=86zf0ts739.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