linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: hisi: Add missing of_node_put after of_find_compatible_node
@ 2022-04-28 10:43 Peng Wu
  2022-05-07  8:25 ` Wei Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Peng Wu @ 2022-04-28 10:43 UTC (permalink / raw)
  To: xuwei5, linux
  Cc: linux-arm-kernel, linux-kernel, liwei391, wangxiongfeng2, Peng Wu

of_find_compatible_node  will increment the refcount of the returned
device_node. Calling of_node_put() to avoid the refcount leak

Signed-off-by: Peng Wu <wupeng58@huawei.com>
---
 arch/arm/mach-hisi/platsmp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-hisi/platsmp.c b/arch/arm/mach-hisi/platsmp.c
index a56cc64deeb8..9ce93e0b6cdc 100644
--- a/arch/arm/mach-hisi/platsmp.c
+++ b/arch/arm/mach-hisi/platsmp.c
@@ -67,14 +67,17 @@ static void __init hi3xxx_smp_prepare_cpus(unsigned int max_cpus)
 		}
 		ctrl_base = of_iomap(np, 0);
 		if (!ctrl_base) {
+			of_node_put(np);
 			pr_err("failed to map address\n");
 			return;
 		}
 		if (of_property_read_u32(np, "smp-offset", &offset) < 0) {
+			of_node_put(np);
 			pr_err("failed to find smp-offset property\n");
 			return;
 		}
 		ctrl_base += offset;
+		of_node_put(np);
 	}
 }
 
@@ -160,6 +163,7 @@ static int hip01_boot_secondary(unsigned int cpu, struct task_struct *idle)
 	if (WARN_ON(!node))
 		return -1;
 	ctrl_base = of_iomap(node, 0);
+	of_node_put(node);
 
 	/* set the secondary core boot from DDR */
 	remap_reg_value = readl_relaxed(ctrl_base + REG_SC_CTRL);
-- 
2.17.1


_______________________________________________
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] 2+ messages in thread

* Re: [PATCH] ARM: hisi: Add missing of_node_put after of_find_compatible_node
  2022-04-28 10:43 [PATCH] ARM: hisi: Add missing of_node_put after of_find_compatible_node Peng Wu
@ 2022-05-07  8:25 ` Wei Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Wei Xu @ 2022-05-07  8:25 UTC (permalink / raw)
  To: Peng Wu, linux
  Cc: linux-arm-kernel, linux-kernel, liwei391, wangxiongfeng2, xuwei5

Hi Peng,

On 2022/4/28 18:43, Peng Wu wrote:
> of_find_compatible_node  will increment the refcount of the returned
> device_node. Calling of_node_put() to avoid the refcount leak
> 
> Signed-off-by: Peng Wu <wupeng58@huawei.com>

Thanks!
Applied to the hisilicon armv7 SoC tree.

Best Regards,
Wei

> ---
>  arch/arm/mach-hisi/platsmp.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm/mach-hisi/platsmp.c b/arch/arm/mach-hisi/platsmp.c
> index a56cc64deeb8..9ce93e0b6cdc 100644
> --- a/arch/arm/mach-hisi/platsmp.c
> +++ b/arch/arm/mach-hisi/platsmp.c
> @@ -67,14 +67,17 @@ static void __init hi3xxx_smp_prepare_cpus(unsigned int max_cpus)
>  		}
>  		ctrl_base = of_iomap(np, 0);
>  		if (!ctrl_base) {
> +			of_node_put(np);
>  			pr_err("failed to map address\n");
>  			return;
>  		}
>  		if (of_property_read_u32(np, "smp-offset", &offset) < 0) {
> +			of_node_put(np);
>  			pr_err("failed to find smp-offset property\n");
>  			return;
>  		}
>  		ctrl_base += offset;
> +		of_node_put(np);
>  	}
>  }
>  
> @@ -160,6 +163,7 @@ static int hip01_boot_secondary(unsigned int cpu, struct task_struct *idle)
>  	if (WARN_ON(!node))
>  		return -1;
>  	ctrl_base = of_iomap(node, 0);
> +	of_node_put(node);
>  
>  	/* set the secondary core boot from DDR */
>  	remap_reg_value = readl_relaxed(ctrl_base + REG_SC_CTRL);
> 


_______________________________________________
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] 2+ messages in thread

end of thread, other threads:[~2022-05-07  8:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-28 10:43 [PATCH] ARM: hisi: Add missing of_node_put after of_find_compatible_node Peng Wu
2022-05-07  8:25 ` Wei Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).