Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1382959 > unrolled thread

[PATCH] arm64: spin-table: add missing of_node_put()

Started byMasahiro Yamada <yamada.masahiro@socionext.com>
First post2016-04-20 03:30 +0200
Last post2016-04-20 11:40 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] arm64: spin-table: add missing of_node_put() Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-04-20 03:30 +0200
    Re: [PATCH] arm64: spin-table: add missing of_node_put() Will Deacon <will.deacon@arm.com> - 2016-04-20 11:20 +0200
    Re: [PATCH] arm64: spin-table: add missing of_node_put() Catalin Marinas <catalin.marinas@arm.com> - 2016-04-20 11:40 +0200

#1382959 — [PATCH] arm64: spin-table: add missing of_node_put()

FromMasahiro Yamada <yamada.masahiro@socionext.com>
Date2016-04-20 03:30 +0200
Subject[PATCH] arm64: spin-table: add missing of_node_put()
Message-ID<rpP7R-86l-11@gated-at.bofh.it>
Since of_get_cpu_node() increments refcount, the node should be put.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 arch/arm64/kernel/smp_spin_table.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/kernel/smp_spin_table.c b/arch/arm64/kernel/smp_spin_table.c
index aef3605..18a71bc 100644
--- a/arch/arm64/kernel/smp_spin_table.c
+++ b/arch/arm64/kernel/smp_spin_table.c
@@ -52,6 +52,7 @@ static void write_pen_release(u64 val)
 static int smp_spin_table_cpu_init(unsigned int cpu)
 {
 	struct device_node *dn;
+	int ret;
 
 	dn = of_get_cpu_node(cpu, NULL);
 	if (!dn)
@@ -60,15 +61,15 @@ static int smp_spin_table_cpu_init(unsigned int cpu)
 	/*
 	 * Determine the address from which the CPU is polling.
 	 */
-	if (of_property_read_u64(dn, "cpu-release-addr",
-				 &cpu_release_addr[cpu])) {
+	ret = of_property_read_u64(dn, "cpu-release-addr",
+				   &cpu_release_addr[cpu]);
+	if (ret)
 		pr_err("CPU %d: missing or invalid cpu-release-addr property\n",
 		       cpu);
 
-		return -1;
-	}
+	of_node_put(dn);
 
-	return 0;
+	return ret;
 }
 
 static int smp_spin_table_cpu_prepare(unsigned int cpu)
-- 
1.9.1

[toc] | [next] | [standalone]


#1383190

FromWill Deacon <will.deacon@arm.com>
Date2016-04-20 11:20 +0200
Message-ID<rpWsF-5yx-13@gated-at.bofh.it>
In reply to#1382959
On Wed, Apr 20, 2016 at 10:23:31AM +0900, Masahiro Yamada wrote:
> Since of_get_cpu_node() increments refcount, the node should be put.

Urgh, I really hate the dt refcounting stuff.

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
> 
>  arch/arm64/kernel/smp_spin_table.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arm64/kernel/smp_spin_table.c b/arch/arm64/kernel/smp_spin_table.c
> index aef3605..18a71bc 100644
> --- a/arch/arm64/kernel/smp_spin_table.c
> +++ b/arch/arm64/kernel/smp_spin_table.c
> @@ -52,6 +52,7 @@ static void write_pen_release(u64 val)
>  static int smp_spin_table_cpu_init(unsigned int cpu)
>  {
>  	struct device_node *dn;
> +	int ret;
>  
>  	dn = of_get_cpu_node(cpu, NULL);
>  	if (!dn)
> @@ -60,15 +61,15 @@ static int smp_spin_table_cpu_init(unsigned int cpu)
>  	/*
>  	 * Determine the address from which the CPU is polling.
>  	 */
> -	if (of_property_read_u64(dn, "cpu-release-addr",
> -				 &cpu_release_addr[cpu])) {
> +	ret = of_property_read_u64(dn, "cpu-release-addr",
> +				   &cpu_release_addr[cpu]);
> +	if (ret)
>  		pr_err("CPU %d: missing or invalid cpu-release-addr property\n",
>  		       cpu);
>  
> -		return -1;
> -	}
> +	of_node_put(dn);
>  
> -	return 0;
> +	return ret;


Looks ok to me. The slight change in return code should be harmless for
->cpu_init.

Acked-by: Will Deacon <will.deacon@arm.com>

Will

[toc] | [prev] | [next] | [standalone]


#1383209

FromCatalin Marinas <catalin.marinas@arm.com>
Date2016-04-20 11:40 +0200
Message-ID<rpWM2-5HI-21@gated-at.bofh.it>
In reply to#1382959
On Wed, Apr 20, 2016 at 10:23:31AM +0900, Masahiro Yamada wrote:
> Since of_get_cpu_node() increments refcount, the node should be put.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Queued for 4.6. Thanks.

-- 
Catalin

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web