From: Liviu Dudau <liviu.dudau@arm.com>
To: Weigang He <geoffreyhe2@gmail.com>
Cc: Sudeep Holla <sudeep.holla@kernel.org>,
Lorenzo Pieralisi <lpieralisi@kernel.org>,
Linus Walleij <linusw@kernel.org>,
Russell King <linux@armlinux.org.uk>, Lee Jones <lee@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] ARM: vexpress: fix device_node refcount leak in vexpress_flags_set()
Date: Wed, 30 Sep 2026 21:48:51 +0100 [thread overview]
Message-ID: <ar11s6PaXaXhiswh@e142607> (raw)
In-Reply-To: <20260925173252.933705-2-geoffreyhe2@gmail.com>
On Sat, Sep 26, 2026 at 03:32:51AM +1000, Weigang He wrote:
> vexpress_flags_set() obtains a reference to the "arm,vexpress-sysreg"
> device node via of_find_compatible_node() and passes it to of_iomap(),
> but never calls of_node_put() on it. of_iomap() only reads the node's
> reg property to create the mapping and does not take ownership, so the
> node reference is leaked. The function runs from the __init SMP prepare
> path and caches the mapping in a static, so this is a one-shot leak of a
> single refcount during boot, with no functional impact.
>
> The lookup was added to drivers/mfd/vexpress-sysreg.c by the commit
> below and later moved here by commit 9b06fc39084e ("ARM: vexpress: Move
> vexpress_flags_set() into arch code").
>
> Annotate node with the __free(device_node) cleanup attribute so the
> reference is released when it goes out of scope.
>
> Found by static analysis tool CodeQL.
>
> Fixes: 974cc7b93441 ("mfd: vexpress: Define the device as MFD cells")
> Assisted-by: LLM codeql
> Signed-off-by: Weigang He <geoffreyhe2@gmail.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Best regards,
Liviu
> ---
>
> Notes:
> Compile-tested only (ARCH=arm multi_v7_defconfig, W=1). Not tested on
> hardware; I have no Versatile Express board.
>
> The CodeQL query behind this report was synthesized with LLM assistance,
> and the fix and changelog were drafted with LLM assistance; I have
> reviewed them.
>
> arch/arm/mach-versatile/v2m.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-versatile/v2m.c b/arch/arm/mach-versatile/v2m.c
> index 79afdf2a90b6f..c86b38386cf7c 100644
> --- a/arch/arm/mach-versatile/v2m.c
> +++ b/arch/arm/mach-versatile/v2m.c
> @@ -13,8 +13,8 @@ void vexpress_flags_set(u32 data)
> static void __iomem *base;
>
> if (!base) {
> - struct device_node *node = of_find_compatible_node(NULL, NULL,
> - "arm,vexpress-sysreg");
> + struct device_node *node __free(device_node) =
> + of_find_compatible_node(NULL, NULL, "arm,vexpress-sysreg");
>
> base = of_iomap(node, 0);
> }
> --
> 2.43.0
>
--
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯
next prev parent reply other threads:[~2026-09-30 20:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 17:32 [PATCH 0/2] ARM: vexpress: fix two device_node refcount leaks Weigang He
2026-09-25 17:32 ` [PATCH 1/2] ARM: vexpress: fix device_node refcount leak in vexpress_flags_set() Weigang He
2026-09-30 20:48 ` Liviu Dudau [this message]
2026-09-25 17:32 ` [PATCH 2/2] ARM: vexpress: fix device_node refcount leak in vexpress_smp_dt_prepare_cpus() Weigang He
2026-09-30 20:50 ` Liviu Dudau
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=ar11s6PaXaXhiswh@e142607 \
--to=liviu.dudau@arm.com \
--cc=geoffreyhe2@gmail.com \
--cc=lee@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lpieralisi@kernel.org \
--cc=sudeep.holla@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®