From: Martin Kaiser <martin@kaiser.cx>
To: Weigang He <geoffreyhe2@gmail.com>
Cc: Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ARM: imx: avic: fix device_node refcount leaks in mxc_init_irq()
Date: Wed, 10 Jun 2026 11:42:27 +0200 [thread overview]
Message-ID: <aikxg5xtXWccXPO8@nb282.user.codasip.com> (raw)
In-Reply-To: <20260610053115.2263570-1-geoffreyhe2@gmail.com>
Hi,
Thus wrote Weigang He (geoffreyhe2@gmail.com):
> mxc_init_irq() obtains two device_node references via
> of_find_compatible_node() and never releases either one:
> - The "fsl,imx25-ccm" node (looked up to map the CCM low-power
> interrupt mask registers on i.MX25) is stored in np, used by
> of_iomap(), and then the same np variable is overwritten by the
> second of_find_compatible_node() call without an of_node_put().
> On i.MX25 this leaks the node reference on every boot.
> - The "fsl,avic" node is passed via of_fwnode_handle(np) to
> irq_domain_create_legacy(), which takes its own reference on the
> fwnode through fwnode_handle_get(), so the caller's reference is
> not transferred. np is then leaked at function return.
> Both lookups predate the switch to irq_domain_create_*(); the missing
> puts have been there since the code was introduced.
> Drop each reference once the value derived from it is no longer needed:
> after of_iomap() has mapped the CCM registers, and after
> irq_domain_create_legacy() has taken its own fwnode reference.
> of_node_put() is NULL-safe, so platforms without these nodes are
> unaffected.
> Found by static analysis tool CodeQL.
> Fixes: 544496ab5cbd ("ARM: imx: move irq_domain_add_legacy call into avic driver")
> Fixes: 9b454d16e57d ("ARM: imx: avic: set low-power interrupt mask for imx25")
> Signed-off-by: Weigang He <geoffreyhe2@gmail.com>
> ---
> arch/arm/mach-imx/avic.c | 2 ++
> 1 file changed, 2 insertions(+)
> diff --git a/arch/arm/mach-imx/avic.c b/arch/arm/mach-imx/avic.c
> index 3067c06b4b8eb..6873a50bbe2c0 100644
> --- a/arch/arm/mach-imx/avic.c
> +++ b/arch/arm/mach-imx/avic.c
> @@ -173,6 +173,7 @@ static void __init mxc_init_irq(void __iomem *irqbase)
> np = of_find_compatible_node(NULL, NULL, "fsl,imx25-ccm");
> mx25_ccm_base = of_iomap(np, 0);
> + of_node_put(np);
> if (mx25_ccm_base) {
> /*
> @@ -203,6 +204,7 @@ static void __init mxc_init_irq(void __iomem *irqbase)
> np = of_find_compatible_node(NULL, NULL, "fsl,avic");
> domain = irq_domain_create_legacy(of_fwnode_handle(np), AVIC_NUM_IRQS, irq_base, 0,
> &irq_domain_simple_ops, NULL);
> + of_node_put(np);
> WARN_ON(!domain);
> for (i = 0; i < AVIC_NUM_IRQS / 32; i++, irq_base += 32)
> base-commit: 0f61b1860cc3f52aef9036d7235ed1f017632193
> --
> 2.43.0
Reviewed-by: Martin Kaiser <martin@kaiser.cx>
Thanks,
Martin
prev parent reply other threads:[~2026-06-10 9:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 5:31 [PATCH] ARM: imx: avic: fix device_node refcount leaks in mxc_init_irq() Weigang He
2026-06-10 9:42 ` Martin Kaiser [this message]
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=aikxg5xtXWccXPO8@nb282.user.codasip.com \
--to=martin@kaiser.cx \
--cc=festevam@gmail.com \
--cc=geoffreyhe2@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.