public inbox for linux-pm@vger.kernel.org
 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 2/5] power_supply: charger-manager: " Julia Lawall
  0 siblings, 1 reply; 4+ 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] 4+ 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 ` Julia Lawall
  2015-10-12  2:20   ` Krzysztof Kozlowski
  2015-10-15  8:56   ` Sebastian Reichel
  0 siblings, 2 replies; 4+ 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] 4+ 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; 4+ 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] 4+ 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; 4+ 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] 4+ messages in thread

end of thread, other threads:[~2015-10-15  8:56 UTC | newest]

Thread overview: 4+ 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 2/5] power_supply: charger-manager: " Julia Lawall
2015-10-12  2:20   ` Krzysztof Kozlowski
2015-10-15  8:56   ` Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox