devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: shmobile: R-Mobile: Fix DT refcount bugs in PM domain code
@ 2015-01-14 10:50 Geert Uytterhoeven
  2015-01-14 23:38 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2015-01-14 10:50 UTC (permalink / raw)
  To: Simon Horman, Magnus Damm
  Cc: linux-sh, linux-pm, linux-arm-kernel, devicetree,
	Geert Uytterhoeven

Fix two DT refcount imbalances in the PM domain code that scans the DT
topology:

  1. Add missing of_node_put() after of_find_compatible_node().

  2. If CONFIG_OF_DYNAMIC=y:

	ERROR: Bad of_node_put() on /system-controller@e6180000
	<backtrace>

     of_find_node_by_name() calls of_node_put() on its "from" parameter,
     which must not be done on the for_each_compatible_node() iterator,
     as it causes a zero refcount later.
     Use of_get_child_by_name() instead to fix this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Fixes: d7a3a10c8391fdcd ("ARM: shmobile: R-Mobile: Add DT support for PM domains")
in Simon's git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git
tag renesas-dt-pm-for-v3.20
---
 arch/arm/mach-shmobile/pm-rmobile.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-shmobile/pm-rmobile.c b/arch/arm/mach-shmobile/pm-rmobile.c
index 07fb4ea4d8e94258..85a7fdd9823bc5a6 100644
--- a/arch/arm/mach-shmobile/pm-rmobile.c
+++ b/arch/arm/mach-shmobile/pm-rmobile.c
@@ -270,8 +270,10 @@ static void __init get_special_pds(void)
 
 	/* PM domain containing Coresight-ETM */
 	np = of_find_compatible_node(NULL, NULL, "arm,coresight-etm3x");
-	if (np)
+	if (np) {
 		debug_pd = of_parse_phandle(np, "power-domains", 0);
+		of_node_put(np);
+	}
 }
 
 static void __init put_special_pds(void)
@@ -363,7 +365,7 @@ static int __init rmobile_init_pm_domains(void)
 			continue;
 		}
 
-		pmd = of_find_node_by_name(np, "pm-domains");
+		pmd = of_get_child_by_name(np, "pm-domains");
 		if (!pmd) {
 			pr_warn("%s lacks pm-domains node\n", np->full_name);
 			continue;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ARM: shmobile: R-Mobile: Fix DT refcount bugs in PM domain code
  2015-01-14 10:50 [PATCH] ARM: shmobile: R-Mobile: Fix DT refcount bugs in PM domain code Geert Uytterhoeven
@ 2015-01-14 23:38 ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2015-01-14 23:38 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Magnus Damm, linux-sh, linux-pm, linux-arm-kernel, devicetree

On Wed, Jan 14, 2015 at 11:50:48AM +0100, Geert Uytterhoeven wrote:
> Fix two DT refcount imbalances in the PM domain code that scans the DT
> topology:
> 
>   1. Add missing of_node_put() after of_find_compatible_node().
> 
>   2. If CONFIG_OF_DYNAMIC=y:
> 
> 	ERROR: Bad of_node_put() on /system-controller@e6180000
> 	<backtrace>
> 
>      of_find_node_by_name() calls of_node_put() on its "from" parameter,
>      which must not be done on the for_each_compatible_node() iterator,
>      as it causes a zero refcount later.
>      Use of_get_child_by_name() instead to fix this.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Fixes: d7a3a10c8391fdcd ("ARM: shmobile: R-Mobile: Add DT support for PM domains")
> in Simon's git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git
> tag renesas-dt-pm-for-v3.20

Thanks.

As the patch above is not in the ARM SoC tree yet I have decided
to squash this patch into it.

> ---
>  arch/arm/mach-shmobile/pm-rmobile.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-shmobile/pm-rmobile.c b/arch/arm/mach-shmobile/pm-rmobile.c
> index 07fb4ea4d8e94258..85a7fdd9823bc5a6 100644
> --- a/arch/arm/mach-shmobile/pm-rmobile.c
> +++ b/arch/arm/mach-shmobile/pm-rmobile.c
> @@ -270,8 +270,10 @@ static void __init get_special_pds(void)
>  
>  	/* PM domain containing Coresight-ETM */
>  	np = of_find_compatible_node(NULL, NULL, "arm,coresight-etm3x");
> -	if (np)
> +	if (np) {
>  		debug_pd = of_parse_phandle(np, "power-domains", 0);
> +		of_node_put(np);
> +	}
>  }
>  
>  static void __init put_special_pds(void)
> @@ -363,7 +365,7 @@ static int __init rmobile_init_pm_domains(void)
>  			continue;
>  		}
>  
> -		pmd = of_find_node_by_name(np, "pm-domains");
> +		pmd = of_get_child_by_name(np, "pm-domains");
>  		if (!pmd) {
>  			pr_warn("%s lacks pm-domains node\n", np->full_name);
>  			continue;
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-14 23:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-14 10:50 [PATCH] ARM: shmobile: R-Mobile: Fix DT refcount bugs in PM domain code Geert Uytterhoeven
2015-01-14 23:38 ` Simon Horman

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).