From: Marc Zyngier <maz@kernel.org>
To: Ma Ke <make24@iscas.ac.cn>
Cc: tglx@linutronix.de, Suravee.Suthikulpanit@amd.com,
akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init
Date: Mon, 19 Aug 2024 10:45:38 +0100 [thread overview]
Message-ID: <864j7gzvzx.wl-maz@kernel.org> (raw)
In-Reply-To: <20240819091011.1015745-1-make24@iscas.ac.cn>
On Mon, 19 Aug 2024 10:10:11 +0100,
Ma Ke <make24@iscas.ac.cn> wrote:
>
> Add the missing of_node_put() to release the refcount incremented
> by of_find_matching_node().
>
> Cc: stable@vger.kernel.org
> Fixes: 4266ab1a8ff5 ("irqchip/gic-v2m: Refactor to prepare for ACPI support")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
> drivers/irqchip/irq-gic-v2m.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
> index 51af63c046ed..65a55ee7bb30 100644
> --- a/drivers/irqchip/irq-gic-v2m.c
> +++ b/drivers/irqchip/irq-gic-v2m.c
> @@ -396,6 +396,7 @@ static int __init gicv2m_of_init(struct fwnode_handle *parent_handle,
> ret = of_address_to_resource(child, 0, &res);
> if (ret) {
> pr_err("Failed to allocate v2m resource.\n");
> + of_node_put(child);
> break;
> }
>
Although this indeed fixes a minor issue, it is probably better to
unify all the failure conditions. Something like this (untested):
diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index 51af63c046ed..d5988012eb40 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -407,12 +407,12 @@ static int __init gicv2m_of_init(struct fwnode_handle *parent_handle,
ret = gicv2m_init_one(&child->fwnode, spi_start, nr_spis,
&res, 0);
- if (ret) {
- of_node_put(child);
+ if (ret)
break;
- }
}
+ if (ret && child)
+ of_put_node(child);
if (!ret)
ret = gicv2m_allocate_domains(parent);
if (ret)
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
prev parent reply other threads:[~2024-08-19 9:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-19 9:10 [PATCH] irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init Ma Ke
2024-08-19 9:45 ` Marc Zyngier [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=864j7gzvzx.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=Suravee.Suthikulpanit@amd.com \
--cc=akpm@linux-foundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=make24@iscas.ac.cn \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).