[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1551430616-42014-4-git-send-email-wen.yang99@zte.com.cn>
Date: Fri, 1 Mar 2019 16:56:45 +0800
From: Wen Yang <wen.yang99@....com.cn>
To: liviu.dudau@....com
Cc: sudeep.holla@....com, lorenzo.pieralisi@....com,
linux@...linux.org.uk, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, kgene@...nel.org, krzk@...nel.org,
linux-samsung-soc@...r.kernel.org, michal.simek@...inx.com,
afaerber@...e.de, manivannan.sadhasivam@...aro.org,
dinguyen@...nel.org, heiko@...ech.de,
linux-rockchip@...ts.infradead.org, f.fainelli@...il.com,
rjui@...adcom.com, sbranden@...adcom.com,
bcm-kernel-feedback-list@...adcom.com, linus.walleij@...aro.org,
avifishman70@...il.com, tmaimon77@...il.com, venture@...gle.com,
yuenn@...gle.com, brendanhiggins@...gle.com,
openbmc@...ts.ozlabs.org, xuwei5@...ilicon.com,
maxime.ripard@...tlin.com, wens@...e.org, catalin.marinas@....com,
will.deacon@....com, horms@...ge.net.au, magnus.damm@...il.com,
linux-renesas-soc@...r.kernel.org, shawnguo@...nel.org,
s.hauer@...gutronix.de, kernel@...gutronix.de,
fabio.estevam@....com, linux-imx@....com, wang.yi59@....com.cn,
Wen Yang <wen.yang99@....com.cn>
Subject: [PATCH 04/15] ARM: hisi: fix a leaked reference by addingmissing of_node_put
The call to of_get_next_child returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.
Detected by coccinelle with the following warnings:
./arch/arm/mach-hisi/platsmp.c:74:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function.
./arch/arm/mach-hisi/platsmp.c:78:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function.
./arch/arm/mach-hisi/platmcpm.c:337:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 275, but without a corresponding object release within this function.
./arch/arm/mach-hisi/platmcpm.c:347:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 275, but without a corresponding object release within this function.
./arch/arm/mach-hisi/platmcpm.c:337:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 284, but without a corresponding object release within this function.
./arch/arm/mach-hisi/platmcpm.c:347:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 284, but without a corresponding object release within this function.
./arch/arm/mach-hisi/platmcpm.c:337:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 287, but without a corresponding object release within this function.
./arch/arm/mach-hisi/platmcpm.c:347:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 287, but without a corresponding object release within this function.
Signed-off-by: Wen Yang <wen.yang99@....com.cn>
Cc: Wei Xu <xuwei5@...ilicon.com>
Cc: Russell King <linux@...linux.org.uk>
Cc: linux-arm-kernel@...ts.infradead.org
Cc: linux-kernel@...r.kernel.org
---
arch/arm/mach-hisi/platmcpm.c | 12 ++++++++++--
arch/arm/mach-hisi/platsmp.c | 7 +++++--
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-hisi/platmcpm.c b/arch/arm/mach-hisi/platmcpm.c
index f66815c..695423c 100644
--- a/arch/arm/mach-hisi/platmcpm.c
+++ b/arch/arm/mach-hisi/platmcpm.c
@@ -277,6 +277,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;
@@ -285,12 +286,14 @@ static int __init hip04_smp_init(void)
if (!np_sctl)
goto err;
np_fab = of_find_compatible_node(NULL, NULL, "hisilicon,hip04-fabric");
- if (!np_fab)
+ if (!np_fab) {
+ of_node_put(np_sctl);
goto err;
+ }
ret = memblock_reserve(hip04_boot_method[0], hip04_boot_method[1]);
if (ret)
- goto err;
+ goto err_put_node;
relocation = ioremap(hip04_boot_method[2], hip04_boot_method[3]);
if (!relocation) {
@@ -334,6 +337,8 @@ static int __init hip04_smp_init(void)
iounmap(relocation);
smp_set_ops(&hip04_smp_ops);
+ of_node_put(np_fab);
+ of_node_put(np_sctl);
return ret;
err_table:
iounmap(fabric);
@@ -343,6 +348,9 @@ static int __init hip04_smp_init(void)
iounmap(relocation);
err_reloc:
memblock_free(hip04_boot_method[0], hip04_boot_method[1]);
+err_put_node:
+ of_node_put(np_fab);
+ of_node_put(np_sctl);
err:
return ret;
}
diff --git a/arch/arm/mach-hisi/platsmp.c b/arch/arm/mach-hisi/platsmp.c
index da5689a..ecc68fa 100644
--- a/arch/arm/mach-hisi/platsmp.c
+++ b/arch/arm/mach-hisi/platsmp.c
@@ -71,14 +71,17 @@ static void __init hi3xxx_smp_prepare_cpus(unsigned int max_cpus)
ctrl_base = of_iomap(np, 0);
if (!ctrl_base) {
pr_err("failed to map address\n");
- return;
+ goto out_put_node;
}
if (of_property_read_u32(np, "smp-offset", &offset) < 0) {
pr_err("failed to find smp-offset property\n");
- return;
+ goto out_put_node;
}
ctrl_base += offset;
}
+
+out_put_node:
+ of_node_put(np);
}
static int hi3xxx_boot_secondary(unsigned int cpu, struct task_struct *idle)
--
2.9.5
Powered by blists - more mailing lists