diff mbox

ARM: shmobile: R-Mobile: Fix DT refcount bugs in PM domain code

Message ID 1421232648-15204-1-git-send-email-geert+renesas@glider.be (mailing list archive)
State Superseded
Delegated to: Simon Horman
Headers show

Commit Message

Geert Uytterhoeven Jan. 14, 2015, 10:50 a.m. UTC
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(-)

Comments

Simon Horman Jan. 14, 2015, 11:38 p.m. UTC | #1
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
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;