linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] add missing of_node_put
@ 2015-10-10 12:30 Julia Lawall
  2015-10-10 12:30 ` [PATCH 1/5] backlight: 88pm860x_bl: " Julia Lawall
                   ` (4 more replies)
  0 siblings, 5 replies; 26+ messages in thread
From: Julia Lawall @ 2015-10-10 12:30 UTC (permalink / raw)
  To: linux-pm
  Cc: kernel-janitors, linux-kernel, linux-fbdev, linux-sh,
	linux-arm-kernel, Russell King - ARM Linux, Thomas Petazzoni,
	Andrew Lunn, Bjorn Helgaas, Jason Cooper

for_each_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

The complete semantic patch that fixes this problem is
(http://coccinelle.lip6.fr):

// <smpl>
@@
expression root,e;
local idexpression child;
iterator name for_each_child_of_node;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
+  of_node_put(child);
?  break;
   ...
}
... when != child

@@
expression root,e;
local idexpression child;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
(
   return child;
|
+  of_node_put(child);
?  return ...;
)
   ...
 }
// </smpl>

---

 arch/arm/kernel/devtree.c             |    1 +
 arch/arm/mach-shmobile/pm-rmobile.c   |    4 +++-
 drivers/power/charger-manager.c       |    4 +++-
 drivers/regulator/of_regulator.c      |    1 +
 drivers/video/backlight/88pm860x_bl.c |    1 +
 5 files changed, 9 insertions(+), 2 deletions(-)

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

* [PATCH 1/5] backlight: 88pm860x_bl: add missing of_node_put
  2015-10-10 12:30 [PATCH 0/5] add missing of_node_put Julia Lawall
@ 2015-10-10 12:30 ` Julia Lawall
  2015-10-13  8:15   ` Lee Jones
  2015-10-10 12:30 ` [PATCH 2/5] power_supply: charger-manager: " Julia Lawall
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 26+ messages in thread
From: Julia Lawall @ 2015-10-10 12:30 UTC (permalink / raw)
  To: Jingoo Han
  Cc: kernel-janitors, Lee Jones, Jean-Christophe Plagniol-Villard,
	Tomi Valkeinen, linux-fbdev, linux-kernel,
	Russell King - ARM Linux, Thomas Petazzoni, Andrew Lunn,
	Bjorn Helgaas, Jason Cooper

for_each_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
expression root,e;
local idexpression child;
iterator name for_each_child_of_node;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
+  of_node_put(child);
?  break;
   ...
}
... when != child
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/video/backlight/88pm860x_bl.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c
index 2da5862..6d8dc2c 100644
--- a/drivers/video/backlight/88pm860x_bl.c
+++ b/drivers/video/backlight/88pm860x_bl.c
@@ -180,6 +180,7 @@ static int pm860x_backlight_dt_init(struct platform_device *pdev,
 			data->iset = PM8606_WLED_CURRENT(iset);
 			of_property_read_u32(np, "marvell,88pm860x-pwm",
 					     &data->pwm);
+			of_node_put(np);
 			break;
 		}
 	}


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

* [PATCH 2/5] power_supply: charger-manager: add missing of_node_put
  2015-10-10 12:30 [PATCH 0/5] add missing of_node_put Julia Lawall
  2015-10-10 12:30 ` [PATCH 1/5] backlight: 88pm860x_bl: " Julia Lawall
@ 2015-10-10 12:30 ` Julia Lawall
  2015-10-12  2:20   ` Krzysztof Kozlowski
  2015-10-15  8:56   ` Sebastian Reichel
  2015-10-10 12:30 ` [PATCH 3/5] ARM: shmobile: R-Mobile: " Julia Lawall
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 26+ messages in thread
From: Julia Lawall @ 2015-10-10 12:30 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: kernel-janitors, Dmitry Eremin-Solenikov, David Woodhouse,
	linux-pm, linux-kernel, Russell King - ARM Linux,
	Thomas Petazzoni, Andrew Lunn, Bjorn Helgaas, Jason Cooper

for_each_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
expression root,e;
local idexpression child;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
(
   return child;
|
+  of_node_put(child);
?  return ...;
)
   ...
 }
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/power/charger-manager.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index 907293e..1ea5d1a 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -1581,8 +1581,10 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev)
 				cables = devm_kzalloc(dev, sizeof(*cables)
 						* chg_regs->num_cables,
 						GFP_KERNEL);
-				if (!cables)
+				if (!cables) {
+					of_node_put(child);
 					return ERR_PTR(-ENOMEM);
+				}
 
 				chg_regs->cables = cables;
 


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

* [PATCH 3/5] ARM: shmobile: R-Mobile: add missing of_node_put
  2015-10-10 12:30 [PATCH 0/5] add missing of_node_put Julia Lawall
  2015-10-10 12:30 ` [PATCH 1/5] backlight: 88pm860x_bl: " Julia Lawall
  2015-10-10 12:30 ` [PATCH 2/5] power_supply: charger-manager: " Julia Lawall
@ 2015-10-10 12:30 ` Julia Lawall
  2015-10-12  0:16   ` Simon Horman
  2015-10-12  7:18   ` Geert Uytterhoeven
  2015-10-10 12:30 ` [PATCH 4/5] regulator: of: " Julia Lawall
  2015-10-10 12:30 ` [PATCH 5/5] arm: add missing of_node_put Julia Lawall
  4 siblings, 2 replies; 26+ messages in thread
From: Julia Lawall @ 2015-10-10 12:30 UTC (permalink / raw)
  To: Simon Horman
  Cc: kernel-janitors, Magnus Damm, Russell King, linux-sh,
	linux-arm-kernel, linux-kernel, Thomas Petazzoni, Andrew Lunn,
	Bjorn Helgaas, Jason Cooper

for_each_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
expression root,e;
local idexpression child;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
(
   return child;
|
+  of_node_put(child);
?  return ...;
)
   ...
 }
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 arch/arm/mach-shmobile/pm-rmobile.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-shmobile/pm-rmobile.c b/arch/arm/mach-shmobile/pm-rmobile.c
index 89068c8..46d0a1d 100644
--- a/arch/arm/mach-shmobile/pm-rmobile.c
+++ b/arch/arm/mach-shmobile/pm-rmobile.c
@@ -313,8 +313,10 @@ static int __init rmobile_add_pm_domains(void __iomem *base,
 		}
 
 		pd = kzalloc(sizeof(*pd), GFP_KERNEL);
-		if (!pd)
+		if (!pd) {
+			of_node_put(np);
 			return -ENOMEM;
+		}
 
 		pd->genpd.name = np->name;
 		pd->base = base;


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

* [PATCH 4/5] regulator: of: add missing of_node_put
  2015-10-10 12:30 [PATCH 0/5] add missing of_node_put Julia Lawall
                   ` (2 preceding siblings ...)
  2015-10-10 12:30 ` [PATCH 3/5] ARM: shmobile: R-Mobile: " Julia Lawall
@ 2015-10-10 12:30 ` Julia Lawall
  2015-10-12  0:33   ` Krzysztof Kozlowski
  2018-02-12 12:09   ` Applied "regulator: of: Add a missing 'of_node_put()' in an error handling path of 'of_regulator_match()'" to the regulator tree Mark Brown
  2015-10-10 12:30 ` [PATCH 5/5] arm: add missing of_node_put Julia Lawall
  4 siblings, 2 replies; 26+ messages in thread
From: Julia Lawall @ 2015-10-10 12:30 UTC (permalink / raw)
  To: Liam Girdwood
  Cc: kernel-janitors, Mark Brown, linux-kernel,
	Russell King - ARM Linux, Thomas Petazzoni, Andrew Lunn,
	Bjorn Helgaas, Jason Cooper

for_each_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
expression root,e;
local idexpression child;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
(
   return child;
|
+  of_node_put(child);
?  return ...;
)
   ...
 }
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/regulator/of_regulator.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 499e437..f9d77b4 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -274,6 +274,7 @@ int of_regulator_match(struct device *dev, struct device_node *node,
 				dev_err(dev,
 					"failed to parse DT for regulator %s\n",
 					child->name);
+				of_node_put(child);
 				return -EINVAL;
 			}
 			match->of_node = of_node_get(child);


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

* [PATCH 5/5] arm: add missing of_node_put
  2015-10-10 12:30 [PATCH 0/5] add missing of_node_put Julia Lawall
                   ` (3 preceding siblings ...)
  2015-10-10 12:30 ` [PATCH 4/5] regulator: of: " Julia Lawall
@ 2015-10-10 12:30 ` Julia Lawall
  2015-10-10 21:02   ` Arnd Bergmann
  4 siblings, 1 reply; 26+ messages in thread
From: Julia Lawall @ 2015-10-10 12:30 UTC (permalink / raw)
  To: Russell King
  Cc: kernel-janitors, linux-arm-kernel, linux-kernel,
	Russell King - ARM Linux, Thomas Petazzoni, Andrew Lunn,
	Bjorn Helgaas, Jason Cooper

for_each_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
expression root,e;
local idexpression child;
iterator name for_each_child_of_node;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
+  of_node_put(child);
?  break;
   ...
}
... when != child
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 arch/arm/kernel/devtree.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index 11c54de..432ff34 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -143,6 +143,7 @@ void __init arm_dt_init_cpu_maps(void)
 					       "max cores %u, capping them\n",
 					       cpuidx, nr_cpu_ids)) {
 			cpuidx = nr_cpu_ids;
+			of_node_put(cpu);
 			break;
 		}
 


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

* Re: [PATCH 5/5] arm: add missing of_node_put
  2015-10-10 12:30 ` [PATCH 5/5] arm: add missing of_node_put Julia Lawall
@ 2015-10-10 21:02   ` Arnd Bergmann
  2015-10-10 21:08     ` Thomas Petazzoni
  2015-10-10 21:10     ` Julia Lawall
  0 siblings, 2 replies; 26+ messages in thread
From: Arnd Bergmann @ 2015-10-10 21:02 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Julia Lawall, Russell King, Thomas Petazzoni, Andrew Lunn,
	Jason Cooper, kernel-janitors, linux-kernel, Bjorn Helgaas

On Saturday 10 October 2015 14:30:54 Julia Lawall wrote:
> diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
> index 11c54de..432ff34 100644
> --- a/arch/arm/kernel/devtree.c
> +++ b/arch/arm/kernel/devtree.c
> @@ -143,6 +143,7 @@ void __init arm_dt_init_cpu_maps(void)
>                                                "max cores %u, capping them\n",
>                                                cpuidx, nr_cpu_ids)) {
>                         cpuidx = nr_cpu_ids;
> +                       of_node_put(cpu);
>                         break;
>                 }
> 

The same for_each_child_of_node() loop has three 'return' statements'
aside from the 'break' statement here. I think you should change your
semantic patch to cover both cases.

	Arnd

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

* Re: [PATCH 5/5] arm: add missing of_node_put
  2015-10-10 21:02   ` Arnd Bergmann
@ 2015-10-10 21:08     ` Thomas Petazzoni
  2015-10-10 21:12       ` Julia Lawall
  2015-10-10 21:10     ` Julia Lawall
  1 sibling, 1 reply; 26+ messages in thread
From: Thomas Petazzoni @ 2015-10-10 21:08 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arm-kernel, Julia Lawall, Russell King, Andrew Lunn,
	Jason Cooper, kernel-janitors, linux-kernel, Bjorn Helgaas

Arnd,

On Sat, 10 Oct 2015 23:02:15 +0200, Arnd Bergmann wrote:

> The same for_each_child_of_node() loop has three 'return' statements'
> aside from the 'break' statement here. I think you should change your
> semantic patch to cover both cases.

I think Julia's semantic patch covers both cases, but only the cases
where there is one break or return (though I have essentially zero
Coccinelle knowledge, this is all based on guessing looking at the
semantic patch in the cover letter).

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* Re: [PATCH 5/5] arm: add missing of_node_put
  2015-10-10 21:02   ` Arnd Bergmann
  2015-10-10 21:08     ` Thomas Petazzoni
@ 2015-10-10 21:10     ` Julia Lawall
  2015-10-10 21:15       ` Arnd Bergmann
  1 sibling, 1 reply; 26+ messages in thread
From: Julia Lawall @ 2015-10-10 21:10 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arm-kernel, Julia Lawall, Russell King, Thomas Petazzoni,
	Andrew Lunn, Jason Cooper, kernel-janitors, linux-kernel,
	Bjorn Helgaas

On Sat, 10 Oct 2015, Arnd Bergmann wrote:

> On Saturday 10 October 2015 14:30:54 Julia Lawall wrote:
> > diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
> > index 11c54de..432ff34 100644
> > --- a/arch/arm/kernel/devtree.c
> > +++ b/arch/arm/kernel/devtree.c
> > @@ -143,6 +143,7 @@ void __init arm_dt_init_cpu_maps(void)
> >                                                "max cores %u, capping them\n",
> >                                                cpuidx, nr_cpu_ids)) {
> >                         cpuidx = nr_cpu_ids;
> > +                       of_node_put(cpu);
> >                         break;
> >                 }
> > 
> 
> The same for_each_child_of_node() loop has three 'return' statements'
> aside from the 'break' statement here. I think you should change your
> semantic patch to cover both cases.

It was intended to, but it seems that it's not working on the case where 
there is no argument to return.

In any case, it's an opportunity to ask a question.  Would one want a 
of_node_put in front of every return, or should the returns become gotos, 
to a single of_node_put after the current end of the function?

julia

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

* Re: [PATCH 5/5] arm: add missing of_node_put
  2015-10-10 21:08     ` Thomas Petazzoni
@ 2015-10-10 21:12       ` Julia Lawall
  0 siblings, 0 replies; 26+ messages in thread
From: Julia Lawall @ 2015-10-10 21:12 UTC (permalink / raw)
  To: Thomas Petazzoni
  Cc: Arnd Bergmann, linux-arm-kernel, Julia Lawall, Russell King,
	Andrew Lunn, Jason Cooper, kernel-janitors, linux-kernel,
	Bjorn Helgaas

On Sat, 10 Oct 2015, Thomas Petazzoni wrote:

> Arnd,
> 
> On Sat, 10 Oct 2015 23:02:15 +0200, Arnd Bergmann wrote:
> 
> > The same for_each_child_of_node() loop has three 'return' statements'
> > aside from the 'break' statement here. I think you should change your
> > semantic patch to cover both cases.
> 
> I think Julia's semantic patch covers both cases, but only the cases
> where there is one break or return (though I have essentially zero
> Coccinelle knowledge, this is all based on guessing looking at the
> semantic patch in the cover letter).

Normally, it should be OK with lots of returns.  And contrary to my 
previous email, even with return;.  Will check on it.

julia

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

* Re: [PATCH 5/5] arm: add missing of_node_put
  2015-10-10 21:10     ` Julia Lawall
@ 2015-10-10 21:15       ` Arnd Bergmann
  2015-10-10 21:41         ` [PATCH 5/5 v2] " Julia Lawall
  0 siblings, 1 reply; 26+ messages in thread
From: Arnd Bergmann @ 2015-10-10 21:15 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-arm-kernel, Julia Lawall, Russell King, Thomas Petazzoni,
	Andrew Lunn, Jason Cooper, kernel-janitors, linux-kernel,
	Bjorn Helgaas

On Saturday 10 October 2015 23:10:06 Julia Lawall wrote:
> On Sat, 10 Oct 2015, Arnd Bergmann wrote:
> 
> > On Saturday 10 October 2015 14:30:54 Julia Lawall wrote:
> > > diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
> > > index 11c54de..432ff34 100644
> > > --- a/arch/arm/kernel/devtree.c
> > > +++ b/arch/arm/kernel/devtree.c
> > > @@ -143,6 +143,7 @@ void __init arm_dt_init_cpu_maps(void)
> > >                                                "max cores %u, capping them\n",
> > >                                                cpuidx, nr_cpu_ids)) {
> > >                         cpuidx = nr_cpu_ids;
> > > +                       of_node_put(cpu);
> > >                         break;
> > >                 }
> > > 
> > 
> > The same for_each_child_of_node() loop has three 'return' statements'
> > aside from the 'break' statement here. I think you should change your
> > semantic patch to cover both cases.
> 
> It was intended to,

Ok, I saw that just after replying...

> but it seems that it's not working on the case where 
> there is no argument to return.

> In any case, it's an opportunity to ask a question.  Would one want a 
> of_node_put in front of every return, or should the returns become gotos, 
> to a single of_node_put after the current end of the function?

The two styles that I see in code I consider particularly clean are:

- have only one return statement in the function and use goto for
  error handling

- avoid the goto and have the early return.

Mixing the two tends to make the function less readable, so I'd only
change it to use gotos if it can be done nicely for all cases.

	Arnd

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

* [PATCH 5/5 v2] arm: add missing of_node_put
  2015-10-10 21:15       ` Arnd Bergmann
@ 2015-10-10 21:41         ` Julia Lawall
  0 siblings, 0 replies; 26+ messages in thread
From: Julia Lawall @ 2015-10-10 21:41 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arm-kernel, Russell King, Thomas Petazzoni, Andrew Lunn,
	Jason Cooper, kernel-janitors, linux-kernel, Bjorn Helgaas

for_each_child_of_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

The of_node_put is duplicated in front of each error return, because the
function contains a later error return that is beyond the end of the
for_each_child_of_node and thus doesn't need of_node_put.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
expression root,e;
local idexpression child;
iterator name for_each_child_of_node;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
(
   return child;
|
+  of_node_put(child);
?  return ...;
)
   ...
 }

@@
expression root,e;
local idexpression child;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
+  of_node_put(child);
?  break;
   ...
}
... when != child
// </smpl>

Additionally, concatenated a string in an affected line to avoid introducing
a checkpatch warning.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---

v2: Fixed the returns as well, adjusted a string in a test expression.

 arch/arm/kernel/devtree.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index 11c54de..65addcb 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -101,6 +101,7 @@ void __init arm_dt_init_cpu_maps(void)
 		if (of_property_read_u32(cpu, "reg", &hwid)) {
 			pr_debug(" * %s missing reg property\n",
 				     cpu->full_name);
+			of_node_put(cpu);
 			return;
 		}
 
@@ -108,8 +109,10 @@ void __init arm_dt_init_cpu_maps(void)
 		 * 8 MSBs must be set to 0 in the DT since the reg property
 		 * defines the MPIDR[23:0].
 		 */
-		if (hwid & ~MPIDR_HWID_BITMASK)
+		if (hwid & ~MPIDR_HWID_BITMASK) {
+			of_node_put(cpu);
 			return;
+		}
 
 		/*
 		 * Duplicate MPIDRs are a recipe for disaster.
@@ -119,9 +122,11 @@ void __init arm_dt_init_cpu_maps(void)
 		 * to avoid matching valid MPIDR[23:0] values.
 		 */
 		for (j = 0; j < cpuidx; j++)
-			if (WARN(tmp_map[j] == hwid, "Duplicate /cpu reg "
-						     "properties in the DT\n"))
+			if (WARN(tmp_map[j] == hwid,
+				 "Duplicate /cpu reg properties in the DT\n")) {
+				of_node_put(cpu);
 				return;
+			}
 
 		/*
 		 * Build a stashed array of MPIDR values. Numbering scheme
@@ -143,6 +148,7 @@ void __init arm_dt_init_cpu_maps(void)
 					       "max cores %u, capping them\n",
 					       cpuidx, nr_cpu_ids)) {
 			cpuidx = nr_cpu_ids;
+			of_node_put(cpu);
 			break;
 		}
 

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

* Re: [PATCH 3/5] ARM: shmobile: R-Mobile: add missing of_node_put
  2015-10-10 12:30 ` [PATCH 3/5] ARM: shmobile: R-Mobile: " Julia Lawall
@ 2015-10-12  0:16   ` Simon Horman
  2015-10-12  7:18   ` Geert Uytterhoeven
  1 sibling, 0 replies; 26+ messages in thread
From: Simon Horman @ 2015-10-12  0:16 UTC (permalink / raw)
  To: Julia Lawall
  Cc: kernel-janitors, Magnus Damm, Russell King, linux-sh,
	linux-arm-kernel, linux-kernel, Thomas Petazzoni, Andrew Lunn,
	Bjorn Helgaas, Jason Cooper

On Sat, Oct 10, 2015 at 02:30:52PM +0200, Julia Lawall wrote:
> for_each_child_of_node performs an of_node_get on each iteration, so
> a break out of the loop requires an of_node_put.
> 
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
> 
> // <smpl>
> @@
> expression root,e;
> local idexpression child;
> @@
> 
>  for_each_child_of_node(root, child) {
>    ... when != of_node_put(child)
>        when != e = child
> (
>    return child;
> |
> +  of_node_put(child);
> ?  return ...;
> )
>    ...
>  }
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Thanks, I have queued this up as a cleanup for v4.4.

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

* Re: [PATCH 4/5] regulator: of: add missing of_node_put
  2015-10-10 12:30 ` [PATCH 4/5] regulator: of: " Julia Lawall
@ 2015-10-12  0:33   ` Krzysztof Kozlowski
  2015-10-12  5:35     ` Julia Lawall
  2015-10-12 12:44     ` Julia Lawall
  2018-02-12 12:09   ` Applied "regulator: of: Add a missing 'of_node_put()' in an error handling path of 'of_regulator_match()'" to the regulator tree Mark Brown
  1 sibling, 2 replies; 26+ messages in thread
From: Krzysztof Kozlowski @ 2015-10-12  0:33 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Liam Girdwood, kernel-janitors, Mark Brown, linux-kernel,
	Russell King - ARM Linux, Thomas Petazzoni, Andrew Lunn,
	Bjorn Helgaas, Jason Cooper

2015-10-10 21:30 GMT+09:00 Julia Lawall <Julia.Lawall@lip6.fr>:
>
> for_each_child_of_node performs an of_node_get on each iteration, so
> a break out of the loop requires an of_node_put.
>
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> expression root,e;
> local idexpression child;
> @@
>
>  for_each_child_of_node(root, child) {
>    ... when != of_node_put(child)
>        when != e = child
> (
>    return child;
> |
> +  of_node_put(child);
> ?  return ...;
> )
>    ...
>  }
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
>  drivers/regulator/of_regulator.c |    1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
> index 499e437..f9d77b4 100644
> --- a/drivers/regulator/of_regulator.c
> +++ b/drivers/regulator/of_regulator.c
> @@ -274,6 +274,7 @@ int of_regulator_match(struct device *dev, struct device_node *node,
>                                 dev_err(dev,
>                                         "failed to parse DT for regulator %s\n",
>                                         child->name);
> +                               of_node_put(child);

This looks good.

>                                 return -EINVAL;
>                         }
>                         match->of_node = of_node_get(child);

But what about 'break' few lines below? The reference from last
of_get_next_child() should be also dropped because... or we should
remove this of_node_get() call.

How about fixing also usage of for_each_available_child_of_node() in
regulator_of_get_init_data()?

Best regards,
Krzysztof

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

* Re: [PATCH 2/5] power_supply: charger-manager: add missing of_node_put
  2015-10-10 12:30 ` [PATCH 2/5] power_supply: charger-manager: " Julia Lawall
@ 2015-10-12  2:20   ` Krzysztof Kozlowski
  2015-10-15  8:56   ` Sebastian Reichel
  1 sibling, 0 replies; 26+ messages in thread
From: Krzysztof Kozlowski @ 2015-10-12  2:20 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Sebastian Reichel, kernel-janitors, Dmitry Eremin-Solenikov,
	David Woodhouse, linux-pm, linux-kernel,
	Russell King - ARM Linux, Thomas Petazzoni, Andrew Lunn,
	Bjorn Helgaas, Jason Cooper

2015-10-10 21:30 GMT+09:00 Julia Lawall <Julia.Lawall@lip6.fr>:
> for_each_child_of_node performs an of_node_get on each iteration, so
> a break out of the loop requires an of_node_put.
>
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> expression root,e;
> local idexpression child;
> @@
>
>  for_each_child_of_node(root, child) {
>    ... when != of_node_put(child)
>        when != e = child
> (
>    return child;
> |
> +  of_node_put(child);
> ?  return ...;
> )
>    ...
>  }
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
>  drivers/power/charger-manager.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>

Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

Best regards,
Krzysztof

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

* Re: [PATCH 4/5] regulator: of: add missing of_node_put
  2015-10-12  0:33   ` Krzysztof Kozlowski
@ 2015-10-12  5:35     ` Julia Lawall
  2015-10-12 12:44     ` Julia Lawall
  1 sibling, 0 replies; 26+ messages in thread
From: Julia Lawall @ 2015-10-12  5:35 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Liam Girdwood, kernel-janitors, Mark Brown, linux-kernel,
	Russell King - ARM Linux, Thomas Petazzoni, Andrew Lunn,
	Bjorn Helgaas, Jason Cooper



On Mon, 12 Oct 2015, Krzysztof Kozlowski wrote:

> 2015-10-10 21:30 GMT+09:00 Julia Lawall <Julia.Lawall@lip6.fr>:
> >
> > for_each_child_of_node performs an of_node_get on each iteration, so
> > a break out of the loop requires an of_node_put.
> >
> > The semantic patch that fixes this problem is as follows
> > (http://coccinelle.lip6.fr):
> >
> > // <smpl>
> > @@
> > expression root,e;
> > local idexpression child;
> > @@
> >
> >  for_each_child_of_node(root, child) {
> >    ... when != of_node_put(child)
> >        when != e = child
> > (
> >    return child;
> > |
> > +  of_node_put(child);
> > ?  return ...;
> > )
> >    ...
> >  }
> > // </smpl>
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> >
> > ---
> >  drivers/regulator/of_regulator.c |    1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
> > index 499e437..f9d77b4 100644
> > --- a/drivers/regulator/of_regulator.c
> > +++ b/drivers/regulator/of_regulator.c
> > @@ -274,6 +274,7 @@ int of_regulator_match(struct device *dev, struct device_node *node,
> >                                 dev_err(dev,
> >                                         "failed to parse DT for regulator %s\n",
> >                                         child->name);
> > +                               of_node_put(child);
> 
> This looks good.
> 
> >                                 return -EINVAL;
> >                         }
> >                         match->of_node = of_node_get(child);
> 
> But what about 'break' few lines below? The reference from last
> of_get_next_child() should be also dropped because... or we should
> remove this of_node_get() call.
> 
> How about fixing also usage of for_each_available_child_of_node() in
> regulator_of_get_init_data()?

I'll check on all of this and resend.  Thanks for the feedback.

julia

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

* Re: [PATCH 3/5] ARM: shmobile: R-Mobile: add missing of_node_put
  2015-10-10 12:30 ` [PATCH 3/5] ARM: shmobile: R-Mobile: " Julia Lawall
  2015-10-12  0:16   ` Simon Horman
@ 2015-10-12  7:18   ` Geert Uytterhoeven
  2015-10-12  7:24     ` Julia Lawall
  2015-10-12  7:29     ` Thomas Petazzoni
  1 sibling, 2 replies; 26+ messages in thread
From: Geert Uytterhoeven @ 2015-10-12  7:18 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Simon Horman, kernel-janitors, Magnus Damm, Russell King,
	Linux-sh list, linux-arm-kernel, linux-kernel, Thomas Petazzoni,
	Andrew Lunn, Bjorn Helgaas, Jason Cooper

Hi Julia,

On Sat, Oct 10, 2015 at 2:30 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> --- a/arch/arm/mach-shmobile/pm-rmobile.c
> +++ b/arch/arm/mach-shmobile/pm-rmobile.c
> @@ -313,8 +313,10 @@ static int __init rmobile_add_pm_domains(void __iomem *base,
>                 }
>
>                 pd = kzalloc(sizeof(*pd), GFP_KERNEL);
> -               if (!pd)
> +               if (!pd) {
> +                       of_node_put(np);
>                         return -ENOMEM;
> +               }

While technically this patch is correct, the system will be dead anyway if it
ever goes OOM at core_initcall() time.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 3/5] ARM: shmobile: R-Mobile: add missing of_node_put
  2015-10-12  7:18   ` Geert Uytterhoeven
@ 2015-10-12  7:24     ` Julia Lawall
  2015-10-12  7:26       ` Geert Uytterhoeven
  2015-10-12  7:29     ` Thomas Petazzoni
  1 sibling, 1 reply; 26+ messages in thread
From: Julia Lawall @ 2015-10-12  7:24 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Julia Lawall, Simon Horman, kernel-janitors, Magnus Damm,
	Russell King, Linux-sh list, linux-arm-kernel, linux-kernel,
	Thomas Petazzoni, Andrew Lunn, Bjorn Helgaas, Jason Cooper



On Mon, 12 Oct 2015, Geert Uytterhoeven wrote:

> Hi Julia,
>
> On Sat, Oct 10, 2015 at 2:30 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> > --- a/arch/arm/mach-shmobile/pm-rmobile.c
> > +++ b/arch/arm/mach-shmobile/pm-rmobile.c
> > @@ -313,8 +313,10 @@ static int __init rmobile_add_pm_domains(void __iomem *base,
> >                 }
> >
> >                 pd = kzalloc(sizeof(*pd), GFP_KERNEL);
> > -               if (!pd)
> > +               if (!pd) {
> > +                       of_node_put(np);
> >                         return -ENOMEM;
> > +               }
>
> While technically this patch is correct, the system will be dead anyway if it
> ever goes OOM at core_initcall() time.

Maybe it would be better for the code to be correct to serve as an example
(or to avoid serving as a bad example) for others?

julia

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

* Re: [PATCH 3/5] ARM: shmobile: R-Mobile: add missing of_node_put
  2015-10-12  7:24     ` Julia Lawall
@ 2015-10-12  7:26       ` Geert Uytterhoeven
  0 siblings, 0 replies; 26+ messages in thread
From: Geert Uytterhoeven @ 2015-10-12  7:26 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Simon Horman, kernel-janitors, Magnus Damm, Russell King,
	Linux-sh list, linux-arm-kernel, linux-kernel, Thomas Petazzoni,
	Andrew Lunn, Bjorn Helgaas, Jason Cooper

Hi Julia,

On Mon, Oct 12, 2015 at 9:24 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> On Mon, 12 Oct 2015, Geert Uytterhoeven wrote:
>> On Sat, Oct 10, 2015 at 2:30 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
>> > --- a/arch/arm/mach-shmobile/pm-rmobile.c
>> > +++ b/arch/arm/mach-shmobile/pm-rmobile.c
>> > @@ -313,8 +313,10 @@ static int __init rmobile_add_pm_domains(void __iomem *base,
>> >                 }
>> >
>> >                 pd = kzalloc(sizeof(*pd), GFP_KERNEL);
>> > -               if (!pd)
>> > +               if (!pd) {
>> > +                       of_node_put(np);
>> >                         return -ENOMEM;
>> > +               }
>>
>> While technically this patch is correct, the system will be dead anyway if it
>> ever goes OOM at core_initcall() time.
>
> Maybe it would be better for the code to be correct to serve as an example
> (or to avoid serving as a bad example) for others?

Sure, as it's only a single call, that's fine for me.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 3/5] ARM: shmobile: R-Mobile: add missing of_node_put
  2015-10-12  7:18   ` Geert Uytterhoeven
  2015-10-12  7:24     ` Julia Lawall
@ 2015-10-12  7:29     ` Thomas Petazzoni
  2015-10-12  7:30       ` Geert Uytterhoeven
  1 sibling, 1 reply; 26+ messages in thread
From: Thomas Petazzoni @ 2015-10-12  7:29 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Julia Lawall, Simon Horman, kernel-janitors, Magnus Damm,
	Russell King, Linux-sh list, linux-arm-kernel, linux-kernel,
	Andrew Lunn, Bjorn Helgaas, Jason Cooper

Dear Geert Uytterhoeven,

On Mon, 12 Oct 2015 09:18:52 +0200, Geert Uytterhoeven wrote:

> >                 pd = kzalloc(sizeof(*pd), GFP_KERNEL);
> > -               if (!pd)
> > +               if (!pd) {
> > +                       of_node_put(np);
> >                         return -ENOMEM;
> > +               }
> 
> While technically this patch is correct, the system will be dead anyway if it
> ever goes OOM at core_initcall() time.

Then BUG_ON(!pd); ?

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* Re: [PATCH 3/5] ARM: shmobile: R-Mobile: add missing of_node_put
  2015-10-12  7:29     ` Thomas Petazzoni
@ 2015-10-12  7:30       ` Geert Uytterhoeven
  0 siblings, 0 replies; 26+ messages in thread
From: Geert Uytterhoeven @ 2015-10-12  7:30 UTC (permalink / raw)
  To: Thomas Petazzoni
  Cc: Julia Lawall, Simon Horman, kernel-janitors, Magnus Damm,
	Russell King, Linux-sh list, linux-arm-kernel, linux-kernel,
	Andrew Lunn, Bjorn Helgaas, Jason Cooper

On Mon, Oct 12, 2015 at 9:29 AM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> On Mon, 12 Oct 2015 09:18:52 +0200, Geert Uytterhoeven wrote:
>
>> >                 pd = kzalloc(sizeof(*pd), GFP_KERNEL);
>> > -               if (!pd)
>> > +               if (!pd) {
>> > +                       of_node_put(np);
>> >                         return -ENOMEM;
>> > +               }
>>
>> While technically this patch is correct, the system will be dead anyway if it
>> ever goes OOM at core_initcall() time.
>
> Then BUG_ON(!pd); ?

kzalloc() will scream anyway.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 4/5] regulator: of: add missing of_node_put
  2015-10-12  0:33   ` Krzysztof Kozlowski
  2015-10-12  5:35     ` Julia Lawall
@ 2015-10-12 12:44     ` Julia Lawall
  2015-10-12 12:58       ` Krzysztof Kozlowski
  1 sibling, 1 reply; 26+ messages in thread
From: Julia Lawall @ 2015-10-12 12:44 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Liam Girdwood, kernel-janitors, Mark Brown, linux-kernel,
	Russell King - ARM Linux, Thomas Petazzoni, Andrew Lunn,
	Bjorn Helgaas, Jason Cooper



On Mon, 12 Oct 2015, Krzysztof Kozlowski wrote:

> 2015-10-10 21:30 GMT+09:00 Julia Lawall <Julia.Lawall@lip6.fr>:
> >
> > for_each_child_of_node performs an of_node_get on each iteration, so
> > a break out of the loop requires an of_node_put.
> >
> > The semantic patch that fixes this problem is as follows
> > (http://coccinelle.lip6.fr):
> >
> > // <smpl>
> > @@
> > expression root,e;
> > local idexpression child;
> > @@
> >
> >  for_each_child_of_node(root, child) {
> >    ... when != of_node_put(child)
> >        when != e = child
> > (
> >    return child;
> > |
> > +  of_node_put(child);
> > ?  return ...;
> > )
> >    ...
> >  }
> > // </smpl>
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> >
> > ---
> >  drivers/regulator/of_regulator.c |    1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
> > index 499e437..f9d77b4 100644
> > --- a/drivers/regulator/of_regulator.c
> > +++ b/drivers/regulator/of_regulator.c
> > @@ -274,6 +274,7 @@ int of_regulator_match(struct device *dev, struct device_node *node,
> >                                 dev_err(dev,
> >                                         "failed to parse DT for regulator %s\n",
> >                                         child->name);
> > +                               of_node_put(child);
>
> This looks good.
>
> >                                 return -EINVAL;
> >                         }
> >                         match->of_node = of_node_get(child);
>
> But what about 'break' few lines below? The reference from last
> of_get_next_child() should be also dropped because... or we should
> remove this of_node_get() call.

Actually, the break is OK.  It's on the inner for loop, not the
for_each_child_of_node loop.  The for_each_child_of_node will still
decrement the reference count in the normal way.

julia

> How about fixing also usage of for_each_available_child_of_node() in
> regulator_of_get_init_data()?
>
> Best regards,
> Krzysztof
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH 4/5] regulator: of: add missing of_node_put
  2015-10-12 12:44     ` Julia Lawall
@ 2015-10-12 12:58       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 26+ messages in thread
From: Krzysztof Kozlowski @ 2015-10-12 12:58 UTC (permalink / raw)
  To: Julia Lawall
  Cc: k.kozlowski.k, Liam Girdwood, kernel-janitors, Mark Brown,
	linux-kernel, Russell King - ARM Linux, Thomas Petazzoni,
	Andrew Lunn, Bjorn Helgaas, Jason Cooper

W dniu 12.10.2015 o 21:44, Julia Lawall pisze:
> 
> 
> On Mon, 12 Oct 2015, Krzysztof Kozlowski wrote:
> 
>> 2015-10-10 21:30 GMT+09:00 Julia Lawall <Julia.Lawall@lip6.fr>:
>>>
>>> for_each_child_of_node performs an of_node_get on each iteration, so
>>> a break out of the loop requires an of_node_put.
>>>
>>> The semantic patch that fixes this problem is as follows
>>> (http://coccinelle.lip6.fr):
>>>
>>> // <smpl>
>>> @@
>>> expression root,e;
>>> local idexpression child;
>>> @@
>>>
>>>  for_each_child_of_node(root, child) {
>>>    ... when != of_node_put(child)
>>>        when != e = child
>>> (
>>>    return child;
>>> |
>>> +  of_node_put(child);
>>> ?  return ...;
>>> )
>>>    ...
>>>  }
>>> // </smpl>
>>>
>>> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>>>
>>> ---
>>>  drivers/regulator/of_regulator.c |    1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
>>> index 499e437..f9d77b4 100644
>>> --- a/drivers/regulator/of_regulator.c
>>> +++ b/drivers/regulator/of_regulator.c
>>> @@ -274,6 +274,7 @@ int of_regulator_match(struct device *dev, struct device_node *node,
>>>                                 dev_err(dev,
>>>                                         "failed to parse DT for regulator %s\n",
>>>                                         child->name);
>>> +                               of_node_put(child);
>>
>> This looks good.
>>
>>>                                 return -EINVAL;
>>>                         }
>>>                         match->of_node = of_node_get(child);
>>
>> But what about 'break' few lines below? The reference from last
>> of_get_next_child() should be also dropped because... or we should
>> remove this of_node_get() call.
> 
> Actually, the break is OK.  It's on the inner for loop, not the
> for_each_child_of_node loop.  The for_each_child_of_node will still
> decrement the reference count in the normal way.
> 
> julia

Yes, you're right. The patch looks good:
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

Best regards,
Krzysztof

>> How about fixing also usage of for_each_available_child_of_node() in
>> regulator_of_get_init_data()?
>>
>> Best regards,
>> Krzysztof
>> --
>> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 


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

* Re: [PATCH 1/5] backlight: 88pm860x_bl: add missing of_node_put
  2015-10-10 12:30 ` [PATCH 1/5] backlight: 88pm860x_bl: " Julia Lawall
@ 2015-10-13  8:15   ` Lee Jones
  0 siblings, 0 replies; 26+ messages in thread
From: Lee Jones @ 2015-10-13  8:15 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Jingoo Han, kernel-janitors, Jean-Christophe Plagniol-Villard,
	Tomi Valkeinen, linux-fbdev, linux-kernel,
	Russell King - ARM Linux, Thomas Petazzoni, Andrew Lunn,
	Bjorn Helgaas, Jason Cooper

On Sat, 10 Oct 2015, Julia Lawall wrote:

> for_each_child_of_node performs an of_node_get on each iteration, so
> a break out of the loop requires an of_node_put.
> 
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
> 
> // <smpl>
> @@
> expression root,e;
> local idexpression child;
> iterator name for_each_child_of_node;
> @@
> 
>  for_each_child_of_node(root, child) {
>    ... when != of_node_put(child)
>        when != e = child
> +  of_node_put(child);
> ?  break;
>    ...
> }
> ... when != child
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
>  drivers/video/backlight/88pm860x_bl.c |    1 +
>  1 file changed, 1 insertion(+)

Applied, thanks.

> diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c
> index 2da5862..6d8dc2c 100644
> --- a/drivers/video/backlight/88pm860x_bl.c
> +++ b/drivers/video/backlight/88pm860x_bl.c
> @@ -180,6 +180,7 @@ static int pm860x_backlight_dt_init(struct platform_device *pdev,
>  			data->iset = PM8606_WLED_CURRENT(iset);
>  			of_property_read_u32(np, "marvell,88pm860x-pwm",
>  					     &data->pwm);
> +			of_node_put(np);
>  			break;
>  		}
>  	}
> 

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 2/5] power_supply: charger-manager: add missing of_node_put
  2015-10-10 12:30 ` [PATCH 2/5] power_supply: charger-manager: " Julia Lawall
  2015-10-12  2:20   ` Krzysztof Kozlowski
@ 2015-10-15  8:56   ` Sebastian Reichel
  1 sibling, 0 replies; 26+ messages in thread
From: Sebastian Reichel @ 2015-10-15  8:56 UTC (permalink / raw)
  To: Julia Lawall
  Cc: kernel-janitors, Dmitry Eremin-Solenikov, David Woodhouse,
	linux-pm, linux-kernel, Russell King - ARM Linux,
	Thomas Petazzoni, Andrew Lunn, Bjorn Helgaas, Jason Cooper

[-- Attachment #1: Type: text/plain, Size: 625 bytes --]

Hi,

On Sat, Oct 10, 2015 at 02:30:51PM +0200, Julia Lawall wrote:
> for_each_child_of_node performs an of_node_get on each iteration, so
> a break out of the loop requires an of_node_put.
> 
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
> 
> // <smpl>
> @@
> expression root,e;
> local idexpression child;
> @@
> 
>  for_each_child_of_node(root, child) {
>    ... when != of_node_put(child)
>        when != e = child
> (
>    return child;
> |
> +  of_node_put(child);
> ?  return ...;
> )
>    ...
>  }
> // </smpl>

Thanks, queued.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Applied "regulator: of: Add a missing 'of_node_put()' in an error handling path of 'of_regulator_match()'" to the regulator tree
  2015-10-10 12:30 ` [PATCH 4/5] regulator: of: " Julia Lawall
  2015-10-12  0:33   ` Krzysztof Kozlowski
@ 2018-02-12 12:09   ` Mark Brown
  1 sibling, 0 replies; 26+ messages in thread
From: Mark Brown @ 2018-02-12 12:09 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Mark Brown, Liam Girdwood, kernel-janitors, Mark Brown,
	linux-kernel, Russell King - ARM Linux, Thomas Petazzoni,
	Andrew Lunn, Bjorn Helgaas, Jason Cooper, linux-kernel

The patch

   regulator: of: Add a missing 'of_node_put()' in an error handling path of 'of_regulator_match()'

has been applied to the regulator tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 30966861a7a2051457be8c49466887d78cc47e97 Mon Sep 17 00:00:00 2001
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date: Fri, 26 Jan 2018 23:13:44 +0100
Subject: [PATCH] regulator: of: Add a missing 'of_node_put()' in an error
 handling path of 'of_regulator_match()'

If an unlikely failure in 'of_get_regulator_init_data()' occurs, we must
release the reference on the current 'child' node before returning.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/of_regulator.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 092ed6efb3ec..f47264fa1940 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -321,6 +321,7 @@ int of_regulator_match(struct device *dev, struct device_node *node,
 				dev_err(dev,
 					"failed to parse DT for regulator %s\n",
 					child->name);
+				of_node_put(child);
 				return -EINVAL;
 			}
 			match->of_node = of_node_get(child);
-- 
2.16.1

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

end of thread, other threads:[~2018-02-12 12:09 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-10 12:30 [PATCH 0/5] add missing of_node_put Julia Lawall
2015-10-10 12:30 ` [PATCH 1/5] backlight: 88pm860x_bl: " Julia Lawall
2015-10-13  8:15   ` Lee Jones
2015-10-10 12:30 ` [PATCH 2/5] power_supply: charger-manager: " Julia Lawall
2015-10-12  2:20   ` Krzysztof Kozlowski
2015-10-15  8:56   ` Sebastian Reichel
2015-10-10 12:30 ` [PATCH 3/5] ARM: shmobile: R-Mobile: " Julia Lawall
2015-10-12  0:16   ` Simon Horman
2015-10-12  7:18   ` Geert Uytterhoeven
2015-10-12  7:24     ` Julia Lawall
2015-10-12  7:26       ` Geert Uytterhoeven
2015-10-12  7:29     ` Thomas Petazzoni
2015-10-12  7:30       ` Geert Uytterhoeven
2015-10-10 12:30 ` [PATCH 4/5] regulator: of: " Julia Lawall
2015-10-12  0:33   ` Krzysztof Kozlowski
2015-10-12  5:35     ` Julia Lawall
2015-10-12 12:44     ` Julia Lawall
2015-10-12 12:58       ` Krzysztof Kozlowski
2018-02-12 12:09   ` Applied "regulator: of: Add a missing 'of_node_put()' in an error handling path of 'of_regulator_match()'" to the regulator tree Mark Brown
2015-10-10 12:30 ` [PATCH 5/5] arm: add missing of_node_put Julia Lawall
2015-10-10 21:02   ` Arnd Bergmann
2015-10-10 21:08     ` Thomas Petazzoni
2015-10-10 21:12       ` Julia Lawall
2015-10-10 21:10     ` Julia Lawall
2015-10-10 21:15       ` Arnd Bergmann
2015-10-10 21:41         ` [PATCH 5/5 v2] " Julia Lawall

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