Skip to contentSkip to conversation

ARM: imx: Add missing of_node_put()

PATCH Superseded Anson Huang 2 participants 3 messages Feb 13, 2020

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ARM: imx: Add missing of_node_put()

After finishing using device node got from of_find_compatible_node(), of_node_put() needs to be called.

---
Changes since V1:
- correct some of_node_put() place to make sure it is safe to be put.

---
 arch/arm/mach-imx/anatop.c     | 3 +++
 arch/arm/mach-imx/gpc.c        | 1 +
 arch/arm/mach-imx/platsmp.c    | 1 +
 arch/arm/mach-imx/pm-imx6.c    | 2 ++
 arch/arm/mach-imx/pm-imx7ulp.c | 1 +
 5 files changed, 8 insertions(+)
arch/arm/mach-imx/anatop.c +3 -0
index 8fb68c0..5985731 100644
@@ -135,6 +135,7 @@ void __init imx_init_revision_from_anatop(void)
 			void __iomem *src_base;
 			u32 sbmr2;
 
+			of_node_put(np);
 			np = of_find_compatible_node(NULL, NULL,
 						     "fsl,imx6ul-src");
 			src_base = of_iomap(np, 0);
@@ -152,6 +153,8 @@ void __init imx_init_revision_from_anatop(void)
 
 	mxc_set_cpu_type(digprog >> 16 & 0xff);
 	imx_set_soc_revision(revision);
+
+	of_node_put(np);
 }
 
 void __init imx_anatop_init(void)
arch/arm/mach-imx/gpc.c +1 -0
index b5b557f..07f1972 100644
@@ -282,4 +282,5 @@ void __init imx_gpc_check_dt(void)
 		/* map GPC, so that at least CPUidle and WARs keep working */
 		gpc_base = of_iomap(np, 0);
 	}
+	of_node_put(np);
 }
arch/arm/mach-imx/platsmp.c +1 -0
index 2aa2692..cf4e933 100644
@@ -109,6 +109,7 @@ static void __init ls1021a_smp_prepare_cpus(unsigned int max_cpus)
 
 	np = of_find_compatible_node(NULL, NULL, "fsl,ls1021a-dcfg");
 	dcfg_base = of_iomap(np, 0);
+	of_node_put(np);
 	BUG_ON(!dcfg_base);
 
 	paddr = __pa_symbol(secondary_startup);
arch/arm/mach-imx/pm-imx6.c +2 -0
index 1c0ecad..dd34dff 100644
@@ -655,6 +655,8 @@ void __init imx6_pm_ccm_init(const char *ccm_compat)
 
 	if (of_property_read_bool(np, "fsl,pmic-stby-poweroff"))
 		imx6_pm_stby_poweroff_probe();
+
+	of_node_put(np);
 }
 
 void __init imx6q_pm_init(void)
arch/arm/mach-imx/pm-imx7ulp.c +1 -0
index 7b2f738..2e756d8 100644
@@ -62,6 +62,7 @@ void __init imx7ulp_pm_init(void)
 
 	np = of_find_compatible_node(NULL, NULL, "fsl,imx7ulp-smc1");
 	smc1_base = of_iomap(np, 0);
+	of_node_put(np);
 	WARN_ON(!smc1_base);
 
 	imx7ulp_set_lpm(ULP_PM_RUN);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 28 lines · Anson Huang

After finishing using device node got from of_find_compatible_node(), of_node_put() needs to be called.

---
Changes since V1:
- correct some of_node_put() place to make sure it is safe to be put.

---
 arch/arm/mach-imx/anatop.c     | 3 +++
 arch/arm/mach-imx/gpc.c        | 1 +
 arch/arm/mach-imx/platsmp.c    | 1 +
 arch/arm/mach-imx/pm-imx6.c    | 2 ++
 arch/arm/mach-imx/pm-imx7ulp.c | 1 +
 5 files changed, 8 insertions(+)
arch/arm/mach-imx/anatop.c +1 -0
index 8fb68c0..5985731 100644
@@ -135,6 +135,7 @@ void __init imx_init_revision_from_anatop(void)
 			void __iomem *src_base;
 			u32 sbmr2;
 
+			of_node_put(np);
 			np = of_find_compatible_node(NULL, NULL,
 						     "fsl,imx6ul-src");
 			src_base = of_iomap(np, 0);

arch/arm/mach-imx/anatop.c void __init imx_init_revision_from_anatop(void) · line 158

Quoted 6 lines
arch/arm/mach-imx/anatop.c +2 -0
@@ -152,6 +153,8 @@ void __init imx_init_revision_from_anatop(void)
 
 	mxc_set_cpu_type(digprog >> 16 & 0xff);
 	imx_set_soc_revision(revision);
+
+	of_node_put(np);
 }

It would be a bit more natural here IMHO to introduce a second struct device_node * variable for the fsl,imx6ul-src device. Then each of_node_put would belong to exactly one of_find_compatible_node(). (Now the of_node_put() in line 157 frees the fsl,imx6ul-src on i.MX6ULL and fsl,imx6q-anatop on the others.)

The other hunks look fine.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#2 lore raw

Hi, Uwe

Quoted 32 lines

Subject: Re: [PATCH V2] ARM: imx: Add missing of_node_put()

Quoted 29 lines · Anson Huang

After finishing using device node got from of_find_compatible_node(), of_node_put() needs to be called.

---
Changes since V1:
- correct some of_node_put() place to make sure it is safe to be put.

---
 arch/arm/mach-imx/anatop.c     | 3 +++
 arch/arm/mach-imx/gpc.c        | 1 +
 arch/arm/mach-imx/platsmp.c    | 1 +
 arch/arm/mach-imx/pm-imx6.c    | 2 ++
 arch/arm/mach-imx/pm-imx7ulp.c | 1 +
 5 files changed, 8 insertions(+)
arch/arm/mach-imx/anatop.c +1 -0
index 8fb68c0..5985731 100644
@@ -135,6 +135,7 @@ void __init imx_init_revision_from_anatop(void)
 			void __iomem *src_base;
 			u32 sbmr2;
 
+			of_node_put(np);
 			np = of_find_compatible_node(NULL, NULL,
 						     "fsl,imx6ul-src");
 			src_base = of_iomap(np, 0);
@@ -152,6 +153,8 @@ void __init imx_init_revision_from_anatop(void)
 
Quoted 11 lines

arch/arm/mach-imx/anatop.c void __init imx_init_revision_from_anatop(void) · line 158

Quoted 5 lines
arch/arm/mach-imx/anatop.c +2 -0
 	mxc_set_cpu_type(digprog >> 16 & 0xff);
 	imx_set_soc_revision(revision);
+
+	of_node_put(np);
 }

It would be a bit more natural here IMHO to introduce a second struct device_node * variable for the fsl,imx6ul-src device. Then each of_node_put would belong to exactly one of_find_compatible_node().
(Now the of_node_put() in line 157 frees the fsl,imx6ul-src on i.MX6ULL and fsl,imx6q-anatop on the others.)

Make sense, please help review V3.
Thanks,
Anson