[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220512081031.24301-1-linmq006@gmail.com>
Date: Thu, 12 May 2022 12:10:31 +0400
From: Miaoqian Lin <linmq006@...il.com>
To: Wei Xu <xuwei5@...ilicon.com>,
Russell King <linux@...linux.org.uk>,
Haojian Zhuang <haojian.zhuang@...aro.org>,
Nicolas Pitre <nico@...xnic.net>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc: linmq006@...il.com
Subject: [PATCH] ARM: hisi: Fix refcount leak in hip04_smp_init
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@...il.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
Powered by blists - more mailing lists