From: Miaoqian Lin <linmq006@gmail.com>
To: Wei Xu <xuwei5@hisilicon.com>,
Russell King <linux@armlinux.org.uk>,
Haojian Zhuang <haojian.zhuang@linaro.org>,
Nicolas Pitre <nico@fluxnic.net>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: linmq006@gmail.com
Subject: [PATCH] ARM: hisi: Fix refcount leak in hip04_smp_init
Date: Thu, 12 May 2022 12:10:31 +0400 [thread overview]
Message-ID: <20220512081031.24301-1-linmq006@gmail.com> (raw)
of_find_compatible_node() returns a node pointer with refcount
incremented, we should use of_node_put() on it when done.
Add missing of_node_put() to avoid refcount leak.
Fixes: 9cdc99919a95 ("ARM: hisi: enable MCPM implementation")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
arch/arm/mach-hisi/platmcpm.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-hisi/platmcpm.c b/arch/arm/mach-hisi/platmcpm.c
index 258586e31333..e9b5d63ecf4c 100644
--- a/arch/arm/mach-hisi/platmcpm.c
+++ b/arch/arm/mach-hisi/platmcpm.c
@@ -274,6 +274,7 @@ static int __init hip04_smp_init(void)
goto err;
ret = of_property_read_u32_array(np, "boot-method",
&hip04_boot_method[0], 4);
+ of_node_put(np);
if (ret)
goto err;
@@ -283,11 +284,11 @@ static int __init hip04_smp_init(void)
goto err;
np_fab = of_find_compatible_node(NULL, NULL, "hisilicon,hip04-fabric");
if (!np_fab)
- goto err;
+ goto err_put_sctl;
ret = memblock_reserve(hip04_boot_method[0], hip04_boot_method[1]);
if (ret)
- goto err;
+ goto err_put_fab;
relocation = ioremap(hip04_boot_method[2], hip04_boot_method[3]);
if (!relocation) {
@@ -329,6 +330,8 @@ static int __init hip04_smp_init(void)
writel_relaxed(__pa_symbol(secondary_startup), relocation + 8);
writel_relaxed(0, relocation + 12);
iounmap(relocation);
+ of_node_put(np_fab);
+ of_node_put(np_sctl);
smp_set_ops(&hip04_smp_ops);
return ret;
@@ -340,6 +343,10 @@ static int __init hip04_smp_init(void)
iounmap(relocation);
err_reloc:
memblock_phys_free(hip04_boot_method[0], hip04_boot_method[1]);
+err_put_fab:
+ of_node_put(np_fab);
+err_put_sctl:
+ of_node_put(np_sctl);
err:
return ret;
}
--
2.25.1
reply other threads:[~2022-05-12 8:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220512081031.24301-1-linmq006@gmail.com \
--to=linmq006@gmail.com \
--cc=haojian.zhuang@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=nico@fluxnic.net \
--cc=xuwei5@hisilicon.com \
/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®