* [PATCH v3] ARM: rockchip: fix a leaked reference by adding missing of_node_put
@ 2019-04-26 7:08 ` Wen Yang
0 siblings, 0 replies; 11+ messages in thread
From: Wen Yang @ 2019-04-26 7:08 UTC (permalink / raw)
To: linux-kernel
Cc: wang.yi59, Wen Yang, Russell King, Heiko Stuebner,
linux-arm-kernel, linux-rockchip
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-rockchip/pm.c:269:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 259, but without a corresponding object release within this function.
./arch/arm/mach-rockchip/pm.c:275:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 259, but without a corresponding object release within this function
./arch/arm/mach-rockchip/platsmp.c:281:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 272, but without a corresponding object release within this function.
./arch/arm/mach-rockchip/platsmp.c:285:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 272, but without a corresponding object release within this function.
./arch/arm/mach-rockchip/platsmp.c:289:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 272, but without a corresponding object release within this function.
./arch/arm/mach-rockchip/platsmp.c:303:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 294, but without a corresponding object release within this function.
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Suggested-by: Heiko Stuebner <heiko@sntech.de>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
v2: add a missing space between "adding" and "missing"
v3: just add a regular of_node_put
arch/arm/mach-rockchip/platsmp.c | 12 ++++++++++--
arch/arm/mach-rockchip/pm.c | 2 ++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-rockchip/platsmp.c b/arch/arm/mach-rockchip/platsmp.c
index 4675d92..afd1514 100644
--- a/arch/arm/mach-rockchip/platsmp.c
+++ b/arch/arm/mach-rockchip/platsmp.c
@@ -278,19 +278,25 @@ static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus)
sram_base_addr = of_iomap(node, 0);
if (!sram_base_addr) {
pr_err("%s: could not map sram registers\n", __func__);
+ of_node_put(node);
return;
}
- if (has_pmu && rockchip_smp_prepare_pmu())
+ if (has_pmu && rockchip_smp_prepare_pmu()) {
+ of_node_put(node);
return;
+ }
if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) {
- if (rockchip_smp_prepare_sram(node))
+ if (rockchip_smp_prepare_sram(node)) {
+ of_node_put(node);
return;
+ }
/* enable the SCU power domain */
pmu_set_power_domain(PMU_PWRDN_SCU, true);
+ of_node_put(node);
node = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu");
if (!node) {
pr_err("%s: missing scu\n", __func__);
@@ -300,6 +306,7 @@ static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus)
scu_base_addr = of_iomap(node, 0);
if (!scu_base_addr) {
pr_err("%s: could not map scu registers\n", __func__);
+ of_node_put(node);
return;
}
@@ -318,6 +325,7 @@ static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus)
asm ("mrc p15, 1, %0, c9, c0, 2\n" : "=r" (l2ctlr));
ncores = ((l2ctlr >> 24) & 0x3) + 1;
}
+ of_node_put(node);
/* Make sure that all cores except the first are really off */
for (i = 1; i < ncores; i++)
diff --git a/arch/arm/mach-rockchip/pm.c b/arch/arm/mach-rockchip/pm.c
index 065b09e..4a4f914 100644
--- a/arch/arm/mach-rockchip/pm.c
+++ b/arch/arm/mach-rockchip/pm.c
@@ -266,12 +266,14 @@ static int __init rk3288_suspend_init(struct device_node *np)
rk3288_bootram_base = of_iomap(sram_np, 0);
if (!rk3288_bootram_base) {
pr_err("%s: could not map bootram base\n", __func__);
+ of_node_put(sram_np);
return -ENOMEM;
}
ret = of_address_to_resource(sram_np, 0, &res);
if (ret) {
pr_err("%s: could not get bootram phy addr\n", __func__);
+ of_node_put(sram_np);
return ret;
}
rk3288_bootram_phy = res.start;
--
2.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3] ARM: rockchip: fix a leaked reference by adding missing of_node_put
@ 2019-04-26 7:08 ` Wen Yang
0 siblings, 0 replies; 11+ messages in thread
From: Wen Yang @ 2019-04-26 7:08 UTC (permalink / raw)
To: linux-kernel
Cc: wang.yi59, Heiko Stuebner, Russell King, linux-rockchip,
Wen Yang, linux-arm-kernel
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-rockchip/pm.c:269:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 259, but without a corresponding object release within this function.
./arch/arm/mach-rockchip/pm.c:275:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 259, but without a corresponding object release within this function
./arch/arm/mach-rockchip/platsmp.c:281:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 272, but without a corresponding object release within this function.
./arch/arm/mach-rockchip/platsmp.c:285:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 272, but without a corresponding object release within this function.
./arch/arm/mach-rockchip/platsmp.c:289:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 272, but without a corresponding object release within this function.
./arch/arm/mach-rockchip/platsmp.c:303:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 294, but without a corresponding object release within this function.
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Suggested-by: Heiko Stuebner <heiko@sntech.de>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
v2: add a missing space between "adding" and "missing"
v3: just add a regular of_node_put
arch/arm/mach-rockchip/platsmp.c | 12 ++++++++++--
arch/arm/mach-rockchip/pm.c | 2 ++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-rockchip/platsmp.c b/arch/arm/mach-rockchip/platsmp.c
index 4675d92..afd1514 100644
--- a/arch/arm/mach-rockchip/platsmp.c
+++ b/arch/arm/mach-rockchip/platsmp.c
@@ -278,19 +278,25 @@ static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus)
sram_base_addr = of_iomap(node, 0);
if (!sram_base_addr) {
pr_err("%s: could not map sram registers\n", __func__);
+ of_node_put(node);
return;
}
- if (has_pmu && rockchip_smp_prepare_pmu())
+ if (has_pmu && rockchip_smp_prepare_pmu()) {
+ of_node_put(node);
return;
+ }
if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) {
- if (rockchip_smp_prepare_sram(node))
+ if (rockchip_smp_prepare_sram(node)) {
+ of_node_put(node);
return;
+ }
/* enable the SCU power domain */
pmu_set_power_domain(PMU_PWRDN_SCU, true);
+ of_node_put(node);
node = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu");
if (!node) {
pr_err("%s: missing scu\n", __func__);
@@ -300,6 +306,7 @@ static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus)
scu_base_addr = of_iomap(node, 0);
if (!scu_base_addr) {
pr_err("%s: could not map scu registers\n", __func__);
+ of_node_put(node);
return;
}
@@ -318,6 +325,7 @@ static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus)
asm ("mrc p15, 1, %0, c9, c0, 2\n" : "=r" (l2ctlr));
ncores = ((l2ctlr >> 24) & 0x3) + 1;
}
+ of_node_put(node);
/* Make sure that all cores except the first are really off */
for (i = 1; i < ncores; i++)
diff --git a/arch/arm/mach-rockchip/pm.c b/arch/arm/mach-rockchip/pm.c
index 065b09e..4a4f914 100644
--- a/arch/arm/mach-rockchip/pm.c
+++ b/arch/arm/mach-rockchip/pm.c
@@ -266,12 +266,14 @@ static int __init rk3288_suspend_init(struct device_node *np)
rk3288_bootram_base = of_iomap(sram_np, 0);
if (!rk3288_bootram_base) {
pr_err("%s: could not map bootram base\n", __func__);
+ of_node_put(sram_np);
return -ENOMEM;
}
ret = of_address_to_resource(sram_np, 0, &res);
if (ret) {
pr_err("%s: could not get bootram phy addr\n", __func__);
+ of_node_put(sram_np);
return ret;
}
rk3288_bootram_phy = res.start;
--
2.9.5
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [v3] ARM: rockchip: Fix a leaked reference by adding of_node_put() in two functions
2019-04-26 7:08 ` Wen Yang
@ 2019-04-28 6:27 ` Markus Elfring
-1 siblings, 0 replies; 11+ messages in thread
From: Markus Elfring @ 2019-04-28 6:27 UTC (permalink / raw)
To: Wen Yang, Heiko Stübner, linux-arm-kernel, linux-rockchip,
Florian Fainelli
Cc: linux-kernel, Russell King, Yi Wang
> arch/arm/mach-rockchip/platsmp.c | 12 ++++++++++--
> arch/arm/mach-rockchip/pm.c | 2 ++
* Would a commit subject variant be nicer?
* I dare to present a reminder for a recurring development topic.
How do you think about to adjust the exception handling in these function
implementations a bit more according to the Linux coding style
(so that the addition of duplicate function calls would be avoided)?
Regards,
Markus
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [v3] ARM: rockchip: Fix a leaked reference by adding of_node_put() in two functions
@ 2019-04-28 6:27 ` Markus Elfring
0 siblings, 0 replies; 11+ messages in thread
From: Markus Elfring @ 2019-04-28 6:27 UTC (permalink / raw)
To: Wen Yang, Heiko Stübner, linux-arm-kernel, linux-rockchip,
Florian Fainelli
Cc: Yi Wang, linux-kernel, Russell King
> arch/arm/mach-rockchip/platsmp.c | 12 ++++++++++--
> arch/arm/mach-rockchip/pm.c | 2 ++
* Would a commit subject variant be nicer?
* I dare to present a reminder for a recurring development topic.
How do you think about to adjust the exception handling in these function
implementations a bit more according to the Linux coding style
(so that the addition of duplicate function calls would be avoided)?
Regards,
Markus
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [v3] ARM: rockchip: Fix a leaked reference by adding of_node_put() in two functions
2019-04-28 6:27 ` Markus Elfring
@ 2019-04-28 10:40 ` Heiko Stuebner
-1 siblings, 0 replies; 11+ messages in thread
From: Heiko Stuebner @ 2019-04-28 10:40 UTC (permalink / raw)
To: Markus Elfring
Cc: Wen Yang, linux-arm-kernel, linux-rockchip, Florian Fainelli,
linux-kernel, Russell King, Yi Wang
Am Sonntag, 28. April 2019, 08:27:05 CEST schrieb Markus Elfring:
> > arch/arm/mach-rockchip/platsmp.c | 12 ++++++++++--
> > arch/arm/mach-rockchip/pm.c | 2 ++
>
> * Would a commit subject variant be nicer?
yeah, but I'll simply adjust that when applying.
> * I dare to present a reminder for a recurring development topic.
> How do you think about to adjust the exception handling in these function
> implementations a bit more according to the Linux coding style
> (so that the addition of duplicate function calls would be avoided)?
I actually requested not doing wild gotos for of_node_put calls,
as it makes the code harder to read, especially when the "node"
gets reused for a different node-source.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [v3] ARM: rockchip: Fix a leaked reference by adding of_node_put() in two functions
@ 2019-04-28 10:40 ` Heiko Stuebner
0 siblings, 0 replies; 11+ messages in thread
From: Heiko Stuebner @ 2019-04-28 10:40 UTC (permalink / raw)
To: Markus Elfring
Cc: Yi Wang, Florian Fainelli, Russell King, linux-kernel,
linux-rockchip, Wen Yang, linux-arm-kernel
Am Sonntag, 28. April 2019, 08:27:05 CEST schrieb Markus Elfring:
> > arch/arm/mach-rockchip/platsmp.c | 12 ++++++++++--
> > arch/arm/mach-rockchip/pm.c | 2 ++
>
> * Would a commit subject variant be nicer?
yeah, but I'll simply adjust that when applying.
> * I dare to present a reminder for a recurring development topic.
> How do you think about to adjust the exception handling in these function
> implementations a bit more according to the Linux coding style
> (so that the addition of duplicate function calls would be avoided)?
I actually requested not doing wild gotos for of_node_put calls,
as it makes the code harder to read, especially when the "node"
gets reused for a different node-source.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3] ARM: rockchip: fix a leaked reference by adding missing of_node_put
2019-04-26 7:08 ` Wen Yang
@ 2019-04-28 10:46 ` Heiko Stuebner
-1 siblings, 0 replies; 11+ messages in thread
From: Heiko Stuebner @ 2019-04-28 10:46 UTC (permalink / raw)
To: Wen Yang
Cc: linux-kernel, wang.yi59, Russell King, linux-arm-kernel, linux-rockchip
Am Freitag, 26. April 2019, 09:08:08 CEST schrieb Wen Yang:
> 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-rockchip/pm.c:269:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 259, but without a corresponding object release within this function.
> ./arch/arm/mach-rockchip/pm.c:275:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 259, but without a corresponding object release within this function
> ./arch/arm/mach-rockchip/platsmp.c:281:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 272, but without a corresponding object release within this function.
> ./arch/arm/mach-rockchip/platsmp.c:285:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 272, but without a corresponding object release within this function.
> ./arch/arm/mach-rockchip/platsmp.c:289:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 272, but without a corresponding object release within this function.
> ./arch/arm/mach-rockchip/platsmp.c:303:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 294, but without a corresponding object release within this function.
>
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
> Suggested-by: Heiko Stuebner <heiko@sntech.de>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-rockchip@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
queued for 5.3 (too late for 5.2)
Thanks
Heiko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3] ARM: rockchip: fix a leaked reference by adding missing of_node_put
@ 2019-04-28 10:46 ` Heiko Stuebner
0 siblings, 0 replies; 11+ messages in thread
From: Heiko Stuebner @ 2019-04-28 10:46 UTC (permalink / raw)
To: Wen Yang
Cc: wang.yi59, linux-rockchip, linux-kernel, linux-arm-kernel, Russell King
Am Freitag, 26. April 2019, 09:08:08 CEST schrieb Wen Yang:
> 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-rockchip/pm.c:269:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 259, but without a corresponding object release within this function.
> ./arch/arm/mach-rockchip/pm.c:275:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 259, but without a corresponding object release within this function
> ./arch/arm/mach-rockchip/platsmp.c:281:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 272, but without a corresponding object release within this function.
> ./arch/arm/mach-rockchip/platsmp.c:285:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 272, but without a corresponding object release within this function.
> ./arch/arm/mach-rockchip/platsmp.c:289:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 272, but without a corresponding object release within this function.
> ./arch/arm/mach-rockchip/platsmp.c:303:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 294, but without a corresponding object release within this function.
>
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
> Suggested-by: Heiko Stuebner <heiko@sntech.de>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-rockchip@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
queued for 5.3 (too late for 5.2)
Thanks
Heiko
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [v3] ARM: rockchip: Fix a leaked reference by adding of_node_put() in two functions
2019-04-28 10:40 ` Heiko Stuebner
(?)
@ 2019-04-28 10:52 ` Markus Elfring
-1 siblings, 0 replies; 11+ messages in thread
From: Markus Elfring @ 2019-04-28 10:52 UTC (permalink / raw)
To: Heiko Stuebner, linux-arm-kernel, linux-rockchip
Cc: Wen Yang, Florian Fainelli, linux-kernel, Russell King, Yi Wang
>> How do you think about to adjust the exception handling in these function
>> implementations a bit more according to the Linux coding style
>> (so that the addition of duplicate function calls would be avoided)?
>
> I actually requested not doing wild gotos for of_node_put calls,
> as it makes the code harder to read, especially when the "node"
> gets reused for a different node-source.
Does this feedback mean that you insist on another deviation
from the Linux coding style?
Regards,
Markus
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [v3] ARM: rockchip: Fix a leaked reference by adding of_node_put() in two functions
@ 2019-04-28 10:52 ` Markus Elfring
0 siblings, 0 replies; 11+ messages in thread
From: Markus Elfring @ 2019-04-28 10:52 UTC (permalink / raw)
To: Heiko Stuebner,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: Yi Wang, Russell King, Florian Fainelli, Wen Yang,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
>> How do you think about to adjust the exception handling in these function
>> implementations a bit more according to the Linux coding style
>> (so that the addition of duplicate function calls would be avoided)?
>
> I actually requested not doing wild gotos for of_node_put calls,
> as it makes the code harder to read, especially when the "node"
> gets reused for a different node-source.
Does this feedback mean that you insist on another deviation
from the Linux coding style?
Regards,
Markus
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [v3] ARM: rockchip: Fix a leaked reference by adding of_node_put() in two functions
@ 2019-04-28 10:52 ` Markus Elfring
0 siblings, 0 replies; 11+ messages in thread
From: Markus Elfring @ 2019-04-28 10:52 UTC (permalink / raw)
To: Heiko Stuebner, linux-arm-kernel, linux-rockchip
Cc: Yi Wang, Russell King, Florian Fainelli, Wen Yang, linux-kernel
>> How do you think about to adjust the exception handling in these function
>> implementations a bit more according to the Linux coding style
>> (so that the addition of duplicate function calls would be avoided)?
>
> I actually requested not doing wild gotos for of_node_put calls,
> as it makes the code harder to read, especially when the "node"
> gets reused for a different node-source.
Does this feedback mean that you insist on another deviation
from the Linux coding style?
Regards,
Markus
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2019-04-28 10:53 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-26 7:08 [PATCH v3] ARM: rockchip: fix a leaked reference by adding missing of_node_put Wen Yang
2019-04-26 7:08 ` Wen Yang
2019-04-28 6:27 ` [v3] ARM: rockchip: Fix a leaked reference by adding of_node_put() in two functions Markus Elfring
2019-04-28 6:27 ` Markus Elfring
2019-04-28 10:40 ` Heiko Stuebner
2019-04-28 10:40 ` Heiko Stuebner
2019-04-28 10:52 ` Markus Elfring
2019-04-28 10:52 ` Markus Elfring
2019-04-28 10:52 ` Markus Elfring
2019-04-28 10:46 ` [PATCH v3] ARM: rockchip: fix a leaked reference by adding missing of_node_put Heiko Stuebner
2019-04-28 10:46 ` Heiko Stuebner
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.