ARM: actions: fix a leaked reference by adding missing of_node_put
Subsystems (18)
PATCH v2 1/15 ARM: actions: fix a leaked reference by adding missing 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-actions/platsmp.c:112:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 103, but without a corresponding object release within this function. ./arch/arm/mach-actions/platsmp.c:124:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 115, but without a corresponding object release within this function. ./arch/arm/mach-actions/platsmp.c:137:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 128, but without a corresponding object release within this function.
---v2->v1: add a missing space between "adding" and "missing"
arch/arm/mach-actions/platsmp.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/mach-actions/platsmp.c +3 -0
@@ -107,6 +107,7 @@ static void __init s500_smp_prepare_cpus(unsigned int max_cpus) } timer_base_addr =of_iomap (node,0 ); +of_node_put (node);if (!timer_base_addr) {pr_err ("%s: could not map timer registers\n" , __func__);return ;
@@ -119,6 +120,7 @@ static void __init s500_smp_prepare_cpus(unsigned int max_cpus) } sps_base_addr =of_iomap (node,0 ); +of_node_put (node);if (!sps_base_addr) {pr_err ("%s: could not map sps registers\n" , __func__);return ;
@@ -132,6 +134,7 @@ static void __init s500_smp_prepare_cpus(unsigned int max_cpus) } scu_base_addr =of_iomap (node,0 ); +of_node_put (node);if (!scu_base_addr) {pr_err ("%s: could not map scu registers\n" , __func__);return ;
Signature · 1 line
2.9.5
PATCH v2 2/15 ARM: bcm: fix a leaked reference by adding missing 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-bcm/board_bcm281xx.c:43:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 35, but without a corresponding object release within this function.
---v2->v1: add a missing space between "adding" and "missing"
arch/arm/mach-bcm/board_bcm281xx.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-bcm/board_bcm281xx.c +1 -0
@@ -38,6 +38,7 @@ static void bcm281xx_restart(enum reboot_mode mode, const char *cmd)return ; } base =of_iomap (np_wdog,0 ); +of_node_put (np_wdog);if (!base) {pr_emerg ("Couldn't map brcm,kona-wdt\n" );return ;
Signature · 1 line
2.9.5
Re: [PATCH v2 02/15] ARM: bcm: fix a leaked reference by adding missing of_node_put
Quoted 28 lines · Wen Yang
The call to
of_get_next_childreturns 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-bcm/board_bcm281xx.c:43:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 35, but without a corresponding object release within this function.Signed-off-by Wen Yang <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Cc Florian Fainelli <[email protected]>Cc Ray Jui <[email protected]>Cc Scott Branden <[email protected]>Cc Russell King <[email protected]>---
v2->v1: add a missing space between "adding" and "missing"arch/arm/mach-bcm/board_bcm281xx.c | 1 + 1 file changed, 1 insertion(+)arch/arm/mach-bcm/board_bcm281xx.c +0
-0
arch/arm/mach-bcm/board_bcm281xx.c static void bcm281xx_restart(enum reboot_mode mode, const char *cmd) · line 44
Quoted 7 lines
arch/arm/mach-bcm/board_bcm281xx.c +1
-0@@ -38,6 +38,7 @@ static void bcm281xx_restart(enum reboot_mode mode, const char *cmd)return ; } base =of_iomap (np_wdog,0 ); +of_node_put (np_wdog);if (!base) {pr_emerg ("Couldn't map brcm,kona-wdt\n" );return ;
Change looks good to me. Thanks!
Re: [PATCH v2 02/15] ARM: bcm: fix a leaked reference by adding missing of_node_put
Quoted 41 lines · Ray Jui
Quoted 28 lines · Wen Yang
The call to
of_get_next_childreturns 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-bcm/board_bcm281xx.c:43:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 35, but without a corresponding object release within this function.Signed-off-by Wen Yang <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Cc Florian Fainelli <[email protected]>Cc Ray Jui <[email protected]>Cc Scott Branden <[email protected]>Cc Russell King <[email protected]>---
v2->v1: add a missing space between "adding" and "missing"arch/arm/mach-bcm/board_bcm281xx.c | 1 + 1 file changed, 1 insertion(+)arch/arm/mach-bcm/board_bcm281xx.c +0
-0arch/arm/mach-bcm/board_bcm281xx.c static void bcm281xx_restart(enum reboot_mode mode, const char *cmd) · line 44
Quoted 7 lines
arch/arm/mach-bcm/board_bcm281xx.c +1
-0@@ -38,6 +38,7 @@ static void bcm281xx_restart(enum reboot_mode mode, const char *cmd)return ; } base =of_iomap (np_wdog,0 ); +of_node_put (np_wdog);if (!base) {pr_emerg ("Couldn't map brcm,kona-wdt\n" );return ;Change looks good to me. Thanks!
Quoted 2 lines
Acked-by Ray Jui <[email protected]>
Squashed this patch and "[PATCH 1/4] ARM: brcmstb: fix a leaked reference by adding missing of_node_put" into the same commit:
https://github.com/Broadcom/stblinux/commit/ff98f8f6083a7f317463f538e9a21822e1128657
thanks Wen!
Signature · 1 line
Florian
PATCH v2 3/15 ARM: exynos: fix a leaked reference by adding missing of_node_put
In reply to Wen YangThe 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-exynos/firmware.c:201:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 193, but without a corresponding object release within this function. ./arch/arm/mach-exynos/firmware.c:204:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 193, but without a corresponding object release within this function. ./arch/arm/mach-exynos/suspend.c:642:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 634, but without a corresponding object release within this function.
---v2->v1: add a missing space between "adding" and "missing"
arch/arm/mach-exynos/firmware.c | 1 + arch/arm/mach-exynos/suspend.c | 2 ++ 2 files changed, 3 insertions(+)
arch/arm/mach-exynos/firmware.c +1 -0
@@ -196,6 +196,7 @@ bool __init exynos_secure_firmware_available(void)return false; addr =of_get_address (nd,0 ,NULL ,NULL ); +of_node_put (nd);if (!addr) {pr_err ("%s: No address specified.\n" , __func__);return false;
arch/arm/mach-exynos/suspend.c +2 -0
@@ -639,8 +639,10 @@ void __init exynos_pm_init(void)if (WARN_ON (!of_find_property (np,"interrupt-controller" ,NULL ))) {pr_warn ("Outdated DT detected, suspend/resume will NOT work\n" ); +of_node_put (np);return ; } +of_node_put (np); pm_data = (const struct exynos_pm_data *) match->data;
Signature · 7 lines
2.9.5 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 03/15] ARM: exynos: fix a leaked reference by adding missing of_node_put
Quoted 17 lines · Wen Yang
The call to
of_get_next_childreturns 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-exynos/firmware.c:201:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 193, but without a corresponding object release within this function. ./arch/arm/mach-exynos/firmware.c:204:1-7: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 193, but without a corresponding object release within this function. ./arch/arm/mach-exynos/suspend.c:642:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 634, but without a corresponding object release within this function.Signed-off-by Wen Yang <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Cc Russell King <[email protected]>Cc Kukjin Kim <[email protected]>Cc Krzysztof Kozlowski <[email protected]>
Quoted 1 line
---
Thanks, applied, with adjustments in commit msg and removal of Florian's reviewed-by tag (I cannot find his email with review).
Best regards,
Krzysztof
PATCH v2 4/15 ARM: hisi: fix a leaked reference by adding missing of_node_put
In reply to Wen YangThe 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.
---v2->v1: add a missing space between "adding" and "missing"
arch/arm/mach-hisi/platmcpm.c | 12 ++++++++++-- arch/arm/mach-hisi/platsmp.c | 7 +++++-- 2 files changed, 15 insertions(+), 4 deletions(-)
arch/arm/mach-hisi/platmcpm.c +10 -2
@@ -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; }
arch/arm/mach-hisi/platsmp.c +5 -2
@@ -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)
Signature · 7 lines
2.9.5 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 04/15] ARM: hisi: fix a leaked reference by adding missing of_node_put
arch/arm/mach-hisi/platmcpm.c static int __init hip04_smp_init(void) · line 291
Quoted 8 lines
arch/arm/mach-hisi/platmcpm.c +2
-1@@ -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;
I suggest to adjust this source code place in a different way.
if (!np_fab)
+ goto put_sctl_node;
arch/arm/mach-hisi/platmcpm.c static int __init hip04_smp_init(void) · line 296
Quoted 6 lines
arch/arm/mach-hisi/platmcpm.c +2
-1+ } ret =memblock_reserve (hip04_boot_method[0 ], hip04_boot_method[1 ]);if (ret) - goto err; + goto err_put_node;
How do you think about to use the jump label “put_fab_node” instead?
arch/arm/mach-hisi/platmcpm.c static int __init hip04_smp_init(void) · line 298
Quoted 2 lines
arch/arm/mach-hisi/platmcpm.c +0
-0relocation =ioremap (hip04_boot_method[2 ], hip04_boot_method[3 ]);
Regards,
Markus
PATCH v2 5/15 ARM: imx51: fix a leaked reference by adding missing of_node_put
In reply to Wen YangThe 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-imx/mach-imx51.c:64:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 57, but without a corresponding object release within this function.
---v2->v1: add a missing space between "adding" and "missing"
arch/arm/mach-imx/mach-imx51.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-imx/mach-imx51.c +1 -0
@@ -59,6 +59,7 @@ static void __init imx51_m4if_setup(void)return ; m4if_base =of_iomap (np,0 ); +of_node_put (np);if (!m4if_base) {pr_err ("Unable to map M4IF registers\n" );return ;
Signature · 7 lines
2.9.5 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 05/15] ARM: imx51: fix a leaked reference by adding missing of_node_put
Quoted 18 lines · Wen Yang
The call to
of_get_next_childreturns 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-imx/mach-imx51.c:64:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 57, but without a corresponding object release within this function.Signed-off-by Wen Yang <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Cc Russell King <[email protected]>Cc Shawn Guo <[email protected]>Cc Sascha Hauer <[email protected]>Cc Pengutronix Kernel Team <[email protected]>Cc Fabio Estevam <[email protected]>Cc NXP Linux Team <[email protected]>Cc Lucas Stach <[email protected]>
Quoted 2 lines
---
v2->v1: add a missing space between "adding" and "missing"
I fixed it against v1 which I applied on my branch.
Shawn
PATCH v2 6/15 arm: npcm: fix a leaked reference by adding missing of_node_put
In reply to Wen YangThe 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-npcm/platsmp.c:52:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 31, but without a corresponding object release within this function. ./arch/arm/mach-npcm/platsmp.c:68:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 60, but without a corresponding object release within this function.
---v2->v1: add a missing space between "adding" and "missing"
arch/arm/mach-npcm/platsmp.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-npcm/platsmp.c +2 -0
@@ -35,6 +35,7 @@ static int npcm7xx_smp_boot_secondary(unsigned int cpu, goto out; } gcr_base =of_iomap (gcr_np,0 ); +of_node_put (gcr_np);if (!gcr_base) {pr_err ("could not iomap gcr" ); ret = -ENOMEM ;
@@ -63,6 +64,7 @@ static void __init npcm7xx_smp_prepare_cpus(unsigned int max_cpus)return ; } scu_base =of_iomap (scu_np,0 ); +of_node_put (scu_np);if (!scu_base) {pr_err ("could not iomap scu" );return ;
Signature · 1 line
2.9.5
Re: [PATCH v2 06/15] arm: npcm: fix a leaked reference by adding missing of_node_put
Quoted 47 lines · Wen Yang
The call to
of_get_next_childreturns 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-npcm/platsmp.c:52:1-7: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 31, but without a corresponding object release within this function. ./arch/arm/mach-npcm/platsmp.c:68:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 60, but without a corresponding object release within this function.Signed-off-by Wen Yang <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Cc Avi Fishman <[email protected]>Cc Tomer Maimon <[email protected]>Cc Patrick Venture <[email protected]>Cc Nancy Yuen <[email protected]>Cc Brendan Higgins <[email protected]>Cc Russell King <[email protected]>---
v2->v1: add a missing space between "adding" and "missing"arch/arm/mach-npcm/platsmp.c | 2 ++ 1 file changed, 2 insertions(+)arch/arm/mach-npcm/platsmp.c +2
-1@@ -35,6 +35,7 @@ static int npcm7xx_smp_boot_secondary(unsigned int cpu, goto out; } gcr_base =of_iomap (gcr_np,0 ); +of_node_put (gcr_np);if (!gcr_base) {pr_err ("could not iomap gcr" ); ret = -ENOMEM ;@@ -63,6 +64,7 @@ static void __init npcm7xx_smp_prepare_cpus(unsigned int max_cpus)return ; } scu_base =of_iomap (scu_np,0 ); +of_node_put (scu_np);if (!scu_base) {pr_err ("could not iomap scu" );return ; --
Quoted 2 lines
2.9.5
Signature · 2 lines
Regards, Avi
PATCH v2 7/15 ARM: rockchip: fix a leaked reference by adding missing of_node_put
In reply to Wen YangThe 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:280:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 271, but without a corresponding object release within this function. ./arch/arm/mach-rockchip/platsmp.c:284:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 271, but without a corresponding object release within this function. ./arch/arm/mach-rockchip/platsmp.c:288:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 271, but without a corresponding object release within this function. ./arch/arm/mach-rockchip/platsmp.c:302:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 293, but without a corresponding object release within this function. ./arch/arm/mach-rockchip/platsmp.c:250:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function. ./arch/arm/mach-rockchip/platsmp.c:260:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function. ./arch/arm/mach-rockchip/platsmp.c:263:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function.
---v2->v1: add a missing space between "adding" and "missing"
arch/arm/mach-rockchip/platsmp.c | 12 ++++++++---- arch/arm/mach-rockchip/pm.c | 11 ++++++----- 2 files changed, 14 insertions(+), 9 deletions(-)
arch/arm/mach-rockchip/platsmp.c +8 -4
@@ -277,19 +277,20 @@ 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__); -return ; + goto out_put_node; }if (has_pmu &&rockchip_smp_prepare_pmu ()) -return ; + goto out_put_node;if (read_cpuid_part () ==ARM_CPU_PART_CORTEX_A9 ) {if (rockchip_smp_prepare_sram (node)) -return ; + goto out_put_node;/* 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__);
@@ -299,7 +300,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__); -return ; + goto out_put_node; }/*
@@ -321,6 +322,9 @@ static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus)/* Make sure that all cores except the first are really off */ for (i =1 ; i < ncores; i++)pmu_set_power_domain (0 + i, false); + +out_put_node: +of_node_put (node); }static void __init rk3036_smp_prepare_cpus (unsigned int max_cpus)
arch/arm/mach-rockchip/pm.c +6 -5
@@ -266,25 +266,26 @@ static int 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__); -return -ENOMEM ; + ret = -ENOMEM ; + goto out_put_node; } ret =of_address_to_resource (sram_np,0 , &res);if (ret) {pr_err ("%s: could not get bootram phy addr\n" , __func__); -return ret; + goto out_put_node; } rk3288_bootram_phy = res.start; -of_node_put (sram_np); -rk3288_config_bootdata ();/* copy resume code and data to bootsram */ memcpy (rk3288_bootram_base, rockchip_slp_cpu_resume, rk3288_bootram_sz); -return 0 ; +out_put_node: +of_node_put (sram_np); +return ret; }static const struct platform_suspend_ops rk3288_suspend_ops = {
Signature · 1 line
2.9.5
Heiko Stuebner
maintainerRe: [PATCH v2 07/15] ARM: rockchip: fix a leaked reference by adding missing of_node_put
Hi,
sorry that this took so long to look at, but I think it needs a bit of rework, see below:
Am Dienstag, 5. März 2019, 12:33:58 CEST schrieb Wen Yang:
Quoted 34 lines
The call to
of_get_next_childreturns 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: missingof_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: missingof_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:280:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 271, but without a corresponding object release within this function. ./arch/arm/mach-rockchip/platsmp.c:284:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 271, but without a corresponding object release within this function. ./arch/arm/mach-rockchip/platsmp.c:288:3-9: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 271, but without a corresponding object release within this function. ./arch/arm/mach-rockchip/platsmp.c:302:3-9: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 293, but without a corresponding object release within this function. ./arch/arm/mach-rockchip/platsmp.c:250:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function. ./arch/arm/mach-rockchip/platsmp.c:260:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function. ./arch/arm/mach-rockchip/platsmp.c:263:1-7: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function.Signed-off-by Wen Yang <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Cc Russell King <[email protected]>Cc Heiko Stuebner <[email protected]>---
v2->v1: add a missing space between "adding" and "missing"arch/arm/mach-rockchip/platsmp.c | 12 ++++++++---- arch/arm/mach-rockchip/pm.c | 11 ++++++----- 2 files changed, 14 insertions(+), 9 deletions(-)arch/arm/mach-rockchip/platsmp.c +0
-0
arch/arm/mach-rockchip/platsmp.c static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus) · line 277
Quoted 1 line
arch/arm/mach-rockchip/platsmp.c +0
-0@@ -277,19 +277,20 @@ static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus) sram_base_addr =of_iomap (node,0 );
just do the of_node_put here and drop the whole error gotos? Because node in this case only holds the possible pointer to
Quoted 23 lines
arch/arm/mach-rockchip/platsmp.c +4
-3if (!sram_base_addr) {pr_err ("%s: could not map sram registers\n" , __func__); -return ; + goto out_put_node; }if (has_pmu &&rockchip_smp_prepare_pmu ()) -return ; + goto out_put_node;if (read_cpuid_part () ==ARM_CPU_PART_CORTEX_A9 ) {if (rockchip_smp_prepare_sram (node)) -return ; + goto out_put_node;/* 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__);
arch/arm/mach-rockchip/platsmp.c static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus) · line 300
Quoted 1 line
arch/arm/mach-rockchip/platsmp.c +0
-0@@ -299,7 +300,7 @@ static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus) scu_base_addr =of_iomap (node,0 );
similarly just put the scu node here?
Quoted 22 lines
arch/arm/mach-rockchip/platsmp.c +4
-1if (!scu_base_addr) {pr_err ("%s: could not map scu registers\n" , __func__); -return ; + goto out_put_node; }/* @@ -321,6 +322,9 @@ static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus)/* Make sure that all cores except the first are really off */ for (i =1 ; i < ncores; i++)pmu_set_power_domain (0 + i, false); + +out_put_node: +of_node_put (node); }static void __init rk3036_smp_prepare_cpus (unsigned int max_cpus)arch/arm/mach-rockchip/pm.c +0
-0
arch/arm/mach-rockchip/pm.c static int rk3288_suspend_init(struct device_node *np) · line 268
Quoted 3 lines
arch/arm/mach-rockchip/pm.c +0
-0@@ -266,25 +266,26 @@ static int 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__);
just add a regular of_node_put here?
arch/arm/mach-rockchip/pm.c static int rk3288_suspend_init(struct device_node *np) · line 275
Quoted 8 lines
arch/arm/mach-rockchip/pm.c +2
-1-return -ENOMEM ; + ret = -ENOMEM ; + goto out_put_node; } ret =of_address_to_resource (sram_np,0 , &res);if (ret) {pr_err ("%s: could not get bootram phy addr\n" , __func__);
and here as well? Not having to follow gotos might improve readability especially as after here the node isn't used anymore as indicated by the already existing of_node_put below which should be kept.
Heiko
Quoted 21 lines
arch/arm/mach-rockchip/pm.c +4
-4-return ret; + goto out_put_node; } rk3288_bootram_phy = res.start; -of_node_put (sram_np); -rk3288_config_bootdata ();/* copy resume code and data to bootsram */ memcpy (rk3288_bootram_base, rockchip_slp_cpu_resume, rk3288_bootram_sz); -return 0 ; +out_put_node: +of_node_put (sram_np); +return ret; }static const struct platform_suspend_ops rk3288_suspend_ops = {
PATCH v2 8/15 ARM: shmobile: fix a leaked reference by adding missing of_node_put
In reply to Wen YangThe 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-shmobile/pm-rcar-gen2.c:77:2-8: 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-shmobile/pm-rcar-gen2.c:85:2-8: 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-shmobile/pm-rcar-gen2.c:90:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function.
---v2->v1: add a missing space between "adding" and "missing"
arch/arm/mach-shmobile/pm-rcar-gen2.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-shmobile/pm-rcar-gen2.c +1 -0
@@ -72,6 +72,7 @@ void __init rcar_gen2_pm_init(void) } error =of_address_to_resource (np,0 , &res); +of_node_put (np);if (error) {pr_err ("Failed to get smp-sram address: %d\n" , error);return ;
Signature · 1 line
2.9.5
Re: [PATCH v2 08/15] ARM: shmobile: fix a leaked reference by adding missing of_node_put
Quoted 18 lines · Wen Yang
The call to
of_get_next_childreturns 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-shmobile/pm-rcar-gen2.c:77:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function. ./arch/arm/mach-shmobile/pm-rcar-gen2.c:85:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function. ./arch/arm/mach-shmobile/pm-rcar-gen2.c:90:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function.Signed-off-by Wen Yang <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Reviewed-by Geert Uytterhoeven <[email protected]>Cc Simon Horman <[email protected]>Cc Magnus Damm <[email protected]>Cc Russell King <[email protected]>
Quoted 2 lines
---
v2->v1: add a missing space between "adding" and "missing"
Thanks, I have this applied for inclusion in v5.2.
Quoted 18 lines
arch/arm/mach-shmobile/pm-rcar-gen2.c | 1 + 1 file changed, 1 insertion(+)arch/arm/mach-shmobile/pm-rcar-gen2.c +1
-0@@ -72,6 +72,7 @@ void __init rcar_gen2_pm_init(void) } error =of_address_to_resource (np,0 , &res); +of_node_put (np);if (error) {pr_err ("Failed to get smp-sram address: %d\n" , error);return ;Signature · 1 line
2.9.5
PATCH v2 9/15 ARM: socfpga: fix a leaked reference by adding missing of_node_put
In reply to Wen YangThe 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-socfpga/platsmp.c:93:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 85, but without a corresponding object release within this function.
---v2->v1: add a missing space between "adding" and "missing"
arch/arm/mach-socfpga/platsmp.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-socfpga/platsmp.c +1 -0
@@ -89,6 +89,7 @@ static void __init socfpga_smp_prepare_cpus(unsigned int max_cpus) } socfpga_scu_base_addr =of_iomap (np,0 ); +of_node_put (np);if (!socfpga_scu_base_addr)return ;scu_enable (socfpga_scu_base_addr);
Signature · 1 line
2.9.5
PATCH v2 10/15 ARM: sunxi: fix a leaked reference by adding missing of_node_put
In reply to Wen YangThe 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-sunxi/platsmp.c:55:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 46, but without a corresponding object release within this function. ./arch/arm/mach-sunxi/platsmp.c:138:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 129, but without a corresponding object release within this function.
---v2->v1: add a missing space between "adding" and "missing"
arch/arm/mach-sunxi/platsmp.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-sunxi/platsmp.c +2 -0
@@ -50,6 +50,7 @@ static void __init sun6i_smp_prepare_cpus(unsigned int max_cpus) } prcm_membase =of_iomap (node,0 ); +of_node_put (node);if (!prcm_membase) {pr_err ("Couldn't map A31 PRCM registers\n" );return ;
@@ -63,6 +64,7 @@ static void __init sun6i_smp_prepare_cpus(unsigned int max_cpus) } cpucfg_membase =of_iomap (node,0 ); +of_node_put (node);if (!cpucfg_membase)pr_err ("Couldn't map A31 CPU config registers\n" );
Signature · 1 line
2.9.5
[email protected]
AppliedRe: [PATCH v2 10/15] ARM: sunxi: fix a leaked reference by adding missing of_node_put
Quoted 8 lines · Wen Yang
The call to
of_get_next_childreturns 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-sunxi/platsmp.c:55:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 46, but without a corresponding object release within this function. ./arch/arm/mach-sunxi/platsmp.c:138:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 129, but without a corresponding object release within this function.
Quoted 7 lines
Signed-off-by Wen Yang <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Cc Maxime Ripard <[email protected]>Cc Chen-Yu Tsai <[email protected]>Cc Russell King <[email protected]>
Applied, thanks!
Maxime
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 11/15 ARM: versatile: fix a leaked reference by adding missing of_node_put
In reply to Wen YangThe 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-versatile/versatile_dt.c:315:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 302, but without a corresponding object release within this function. ./arch/arm/mach-versatile/versatile_dt.c:320:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 302, but without a corresponding object release within this function.
---v2->v1: add a missing space between "adding" and "missing"
arch/arm/mach-versatile/versatile_dt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/arm/mach-versatile/versatile_dt.c +5 -2
@@ -312,12 +312,12 @@ static void __init versatile_dt_pci_init(void)* driver had it so we will keep it. */ writel (1 , versatile_sys_base +VERSATILE_SYS_PCICTL_OFFSET ); -return ; + goto out_put_node; } newprop =kzalloc (sizeof (*newprop),GFP_KERNEL );if (!newprop) -return ; + goto out_put_node; newprop->name =kstrdup ("status" ,GFP_KERNEL ); newprop->value =kstrdup ("disabled" ,GFP_KERNEL );
@@ -325,6 +325,9 @@ static void __init versatile_dt_pci_init(void)of_update_property (np, newprop);pr_info ("Not plugged into PCI backplane!\n" ); + +out_put_node: +of_node_put (np); }static void __init versatile_dt_init (void )
Signature · 1 line
2.9.5
PATCH v2 12/15 ARM: vexpress: fix a leaked reference by adding missing of_node_put
In reply to Wen YangThe 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-vexpress/dcscb.c:150:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 145, but without a corresponding object release within this function. ./arch/arm/mach-vexpress/dcscb.c:160:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 145, but without a corresponding object release within this function. ./arch/arm/mach-vexpress/dcscb.c:171:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 145, but without a corresponding object release within this function.
---v2->v1: add a missing space between "adding" and "missing"
arch/arm/mach-vexpress/dcscb.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-vexpress/dcscb.c +1 -0
@@ -146,6 +146,7 @@ static int __init dcscb_init(void)if (!node)return -ENODEV ; dcscb_base =of_iomap (node,0 ); +of_node_put (node);if (!dcscb_base)return -EADDRNOTAVAIL ; cfg =readl_relaxed (dcscb_base +DCS_CFG_R );
Signature · 1 line
2.9.5
Re: [PATCH v2 12/15] ARM: vexpress: fix a leaked reference by adding missing of_node_put
Quoted 9 lines · Wen Yang
The call to
of_get_next_childreturns 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-vexpress/dcscb.c:150:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 145, but without a corresponding object release within this function. ./arch/arm/mach-vexpress/dcscb.c:160:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 145, but without a corresponding object release within this function. ./arch/arm/mach-vexpress/dcscb.c:171:1-7: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 145, but without a corresponding object release within this function.
Quoted 4 lines
Signed-off-by Wen Yang <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Cc Liviu Dudau <[email protected]>Cc Sudeep Holla <[email protected]>
I already Acked assuming you have plans to take this as series. There's no cover letter mentioning your plans to merge this or note to individual platform maintainers. Please let us know.
--
Regards,
Sudeep
PATCH v2 13/15 ARM: zynq: fix a leaked reference by adding missing of_node_put
In reply to Wen YangThe 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-zynq/common.c:89:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 80, but without a corresponding object release within this function. ./arch/arm/mach-zynq/common.c:98:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 80, but without a corresponding object release within this function.
---v2->v1: add a missing space between "adding" and "missing"
arch/arm/mach-zynq/common.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-zynq/common.c +1 -0
@@ -84,6 +84,7 @@ static int __init zynq_get_revision(void) } zynq_devcfg_base =of_iomap (np,0 ); +of_node_put (np);if (!zynq_devcfg_base) {pr_err ("%s: Unable to map I/O memory\n" , __func__);return -1 ;
Signature · 1 line
2.9.5
PATCH v2 14/15 arm64: cpu_ops: fix a leaked reference by adding missing of_node_put
In reply to Wen YangThe 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/arm64/kernel/cpu_ops.c:102:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 69, but without a corresponding object release within this function.
---v2->v1: add a missing space between "adding" and "missing"
arch/arm64/kernel/cpu_ops.c | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kernel/cpu_ops.c +1 -0
@@ -85,6 +85,7 @@ static const char *__init cpu_read_enable_method(int cpu)pr_err ("%pOF: missing enable-method property\n" , dn); } +of_node_put (dn); }else { enable_method =acpi_get_enable_method (cpu);if (!enable_method) {
Signature · 1 line
2.9.5
Re: [PATCH v2 14/15] arm64: cpu_ops: fix a leaked reference by adding missing of_node_put
Quoted 24 lines · Wen Yang
The call to
of_get_next_childreturns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage.Detected by coccinelle with the following warnings:
./arch/arm64/kernel/cpu_ops.c:102:1-7: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 69, but without a corresponding object release within this function.Signed-off-by Wen Yang <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>---
v2->v1: add a missing space between "adding" and "missing"arch/arm64/kernel/cpu_ops.c | 1 + 1 file changed, 1 insertion(+)arch/arm64/kernel/cpu_ops.c +0
-0
arch/arm64/kernel/cpu_ops.c static const char *__init cpu_read_enable_method(int cpu) · line 91
Quoted 7 lines
arch/arm64/kernel/cpu_ops.c +1
-0@@ -85,6 +85,7 @@ static const char *__init cpu_read_enable_method(int cpu)pr_err ("%pOF: missing enable-method property\n" , dn); } +of_node_put (dn); }else { enable_method =acpi_get_enable_method (cpu);if (!enable_method) {
Looks about right to me:
How do you plan to get this upstream? Can we just pick this one up via arm64?
Will
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: 答复: Re: [PATCH v2 14/15] arm64: cpu_ops: fix a leaked reference byadding missing of_node_put
Quoted 34 lines · On Wed, Apr 03, 2019 at 01:56:09PM +0800, [email protected] wrote:
Quoted 34 lines
Quoted 24 lines
The call to
of_get_next_childreturns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage.Detected by coccinelle with the following warnings:
./arch/arm64/kernel/cpu_ops.c:102:1-7: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 69, but without a corresponding object release within this function.Signed-off-by Wen Yang <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>---
v2->v1: add a missing space between "adding" and "missing"arch/arm64/kernel/cpu_ops.c | 1 + 1 file changed, 1 insertion(+)arch/arm64/kernel/cpu_ops.c +0
-0arch/arm64/kernel/cpu_ops.c static const char *__init cpu_read_enable_method(int cpu) · line 91
Quoted 7 lines
arch/arm64/kernel/cpu_ops.c +1
-0@@ -85,6 +85,7 @@ static const char *__init cpu_read_enable_method(int cpu)pr_err ("%pOF: missing enable-method property\n" , dn); } +of_node_put (dn); }else { enable_method =acpi_get_enable_method (cpu);if (!enable_method) {Looks about right to me:
Quoted 7 lines
Quoted 4 lines
Acked-by Will Deacon <[email protected]>How do you plan to get this upstream? Can we just pick this one up via arm64?
Ok, thank you.
We are very happy to know that it is useful.
Ok, I picked it up.
Will
PATCH v2 15/15 ARM: axxia: fix a leaked reference by adding missing of_node_put
In reply to Wen YangThe 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-axxia/platsmp.c:46:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 40, but without a corresponding object release within this function. ./arch/arm/mach-axxia/platsmp.c:53:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 40, but without a corresponding object release within this function.
---v2->v1: add a missing space between "adding" and "missing"
arch/arm/mach-axxia/platsmp.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-axxia/platsmp.c +1 -0
@@ -42,6 +42,7 @@ static int axxia_boot_secondary(unsigned int cpu, struct task_struct *idle)return -ENOENT ; syscon =of_iomap (syscon_np,0 ); +of_node_put (syscon_np);if (!syscon)return -ENOMEM ;
Signature · 1 line
2.9.5
Russell King - ARM Linux admin
maintainerQuoted 8 lines · Wen Yang
The call to
of_get_next_childreturns 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-actions/platsmp.c:112:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 103, but without a corresponding object release within this function. ./arch/arm/mach-actions/platsmp.c:124:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 115, but without a corresponding object release within this function. ./arch/arm/mach-actions/platsmp.c:137:3-9: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 128, but without a corresponding object release within this function.
I question this. Your reasoning is that the node is no longer used so the reference count needs to be put.
However, in all these cases, data is read from the nodes properties and the device remains in-use for the life of the kernel. There is a big difference here.
With normal drivers, each device is bound to their associated device node associated with the device. When the device node goes away, then the corresponding device goes away too, which causes the driver to be unbound from the device.
However, there is another class of "driver" which are the ones below, where they are "permanent" devices. These can never go away, even if the device node refcount hits zero and the device node is freed - the device is still present and in-use in the system. So, having the device node refcount hit zero is actually a bug: what that's saying is the system device (eg, SCU) has gone away. If you somehow were to remove the SCU from the system, you'd end up severing the connection between the CPU cores and the rest of the system - obviously resulting in a dead system!
So, what is the point of dropping these refcounts for devices that can never go away - and thus their associated device_node should also never go away?
Quoted 46 lines
Signed-off-by Wen Yang <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Cc "Andreas Färber" <[email protected]>Cc Manivannan Sadhasivam <[email protected]>Cc Russell King <[email protected]>---
v2->v1: add a missing space between "adding" and "missing"arch/arm/mach-actions/platsmp.c | 3 +++ 1 file changed, 3 insertions(+)arch/arm/mach-actions/platsmp.c +3
-0@@ -107,6 +107,7 @@ static void __init s500_smp_prepare_cpus(unsigned int max_cpus) } timer_base_addr =of_iomap (node,0 ); +of_node_put (node);if (!timer_base_addr) {pr_err ("%s: could not map timer registers\n" , __func__);return ;@@ -119,6 +120,7 @@ static void __init s500_smp_prepare_cpus(unsigned int max_cpus) } sps_base_addr =of_iomap (node,0 ); +of_node_put (node);if (!sps_base_addr) {pr_err ("%s: could not map sps registers\n" , __func__);return ;@@ -132,6 +134,7 @@ static void __init s500_smp_prepare_cpus(unsigned int max_cpus) } scu_base_addr =of_iomap (node,0 ); +of_node_put (node);if (!scu_base_addr) {pr_err ("%s: could not map scu registers\n" , __func__);return ;Signature · 1 line
2.9.5
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up
Hi Russel,
Quoted 32 lines · Russell King - ARM Linux admin
Quoted 8 lines · Wen Yang
The call to
of_get_next_childreturns 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-actions/platsmp.c:112:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 103, but without a corresponding object release within this function. ./arch/arm/mach-actions/platsmp.c:124:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 115, but without a corresponding object release within this function. ./arch/arm/mach-actions/platsmp.c:137:3-9: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 128, but without a corresponding object release within this function.I question this. Your reasoning is that the node is no longer used so the reference count needs to be put.
However, in all these cases, data is read from the nodes properties and the device remains in-use for the life of the kernel. There is a big difference here.
With normal drivers, each device is bound to their associated device node associated with the device. When the device node goes away, then the corresponding device goes away too, which causes the driver to be unbound from the device.
However, there is another class of "driver" which are the ones below, where they are "permanent" devices. These can never go away, even if the device node refcount hits zero and the device node is freed - the device is still present and in-use in the system. So, having the device node refcount hit zero is actually a bug: what that's saying is the system device (eg, SCU) has gone away. If you somehow were to remove the SCU from the system, you'd end up severing the connection between the CPU cores and the rest of the system - obviously resulting in a dead system!
Quoted 4 lines
So, what is the point of dropping these refcounts for devices that can never go away - and thus their associated
device_nodeshould also never go away?
Yes, practically we would never hit this case but theoretically we should decrement the refcount for nodes/properties whenever we are done with it. As you know, there are 'n' number of places in kernel where we can see the refcount not being put after use. So I would welcome these kind of patches to set an example for someone who tries to use the of_* calls in future.
IMO, DT should've handled the refcount internally without exposing the pointers to external world.
Thanks,
Mani
Quoted 37 lines
Quoted 37 lines
Signed-off-by Wen Yang <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Cc "Andreas Färber" <[email protected]>Cc Manivannan Sadhasivam <[email protected]>Cc Russell King <[email protected]>---
v2->v1: add a missing space between "adding" and "missing"arch/arm/mach-actions/platsmp.c | 3 +++ 1 file changed, 3 insertions(+)arch/arm/mach-actions/platsmp.c +2
-0@@ -107,6 +107,7 @@ static void __init s500_smp_prepare_cpus(unsigned int max_cpus) } timer_base_addr =of_iomap (node,0 ); +of_node_put (node);if (!timer_base_addr) {pr_err ("%s: could not map timer registers\n" , __func__);return ;@@ -119,6 +120,7 @@ static void __init s500_smp_prepare_cpus(unsigned int max_cpus) } sps_base_addr =of_iomap (node,0 ); +of_node_put (node);if (!sps_base_addr) {pr_err ("%s: could not map sps registers\n" , __func__);return ;@@ -132,6 +134,7 @@ static void __init s500_smp_prepare_cpus(unsigned int max_cpus) }
Quoted 14 lines
Quoted 9 lines
arch/arm/mach-actions/platsmp.c +1
-0scu_base_addr =of_iomap (node,0 ); +of_node_put (node);if (!scu_base_addr) {pr_err ("%s: could not map scu registers\n" , __func__);return ;Signature · 1 line
2.9.5Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Russell King - ARM Linux admin
maintainerQuoted 40 lines · Manivannan Sadhasivam
Hi Russel,
Quoted 32 lines · Russell King - ARM Linux admin
Quoted 8 lines · Wen Yang
The call to
of_get_next_childreturns 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-actions/platsmp.c:112:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 103, but without a corresponding object release within this function. ./arch/arm/mach-actions/platsmp.c:124:2-8: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 115, but without a corresponding object release within this function. ./arch/arm/mach-actions/platsmp.c:137:3-9: ERROR: missingof_node_put; acquired a node pointer with refcount incremented on line 128, but without a corresponding object release within this function.I question this. Your reasoning is that the node is no longer used so the reference count needs to be put.
However, in all these cases, data is read from the nodes properties and the device remains in-use for the life of the kernel. There is a big difference here.
With normal drivers, each device is bound to their associated device node associated with the device. When the device node goes away, then the corresponding device goes away too, which causes the driver to be unbound from the device.
However, there is another class of "driver" which are the ones below, where they are "permanent" devices. These can never go away, even if the device node refcount hits zero and the device node is freed - the device is still present and in-use in the system. So, having the device node refcount hit zero is actually a bug: what that's saying is the system device (eg, SCU) has gone away. If you somehow were to remove the SCU from the system, you'd end up severing the connection between the CPU cores and the rest of the system - obviously resulting in a dead system!
Quoted 4 lines
So, what is the point of dropping these refcounts for devices that can never go away - and thus their associated
device_nodeshould also never go away?
Quoted 8 lines
Yes, practically we would never hit this case but theoretically we should decrement the refcount for nodes/properties whenever we are done with it. As you know, there are 'n' number of places in kernel where we can see the refcount not being put after use. So I would welcome these kind of patches to set an example for someone who tries to use the of_* calls in future.
IMO, DT should've handled the refcount internally without exposing the pointers to external world.
It doesn't, that's my point.
In the case of normal drivers, there's an _extra_ refcount held by the device that is created - see the of_node_get() in of_device_alloc(). This refcount exists for the lifetime of the device structure. That refcount exists for the duration that the device exists, which bounds the lifetime of the availability of the device to the driver.
In effect, while the device driver is bound, there is a refcount on the device node. So, the device node is guaranteed to be around for as long as the device driver is bound to the device.
For the cases being addressed in these patches, there is no driver, so there is no bounding of the lifetime: the expectation is that the lifetime is the duration of the kernel. If such a device node were to be deleted, then there is no way to unbind the driver, and if we have dropped the refcount, the device node will be immediately freed. However, the device is still in use.
These are a different "class" of driver.
Signature · 8 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel