public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] of: resolver: Add missing of_node_put
@ 2016-01-27 15:20 Amitoj Kaur Chawla
  2016-01-27 16:05 ` Mark Rutland
  0 siblings, 1 reply; 12+ messages in thread
From: Amitoj Kaur Chawla @ 2016-01-27 15:20 UTC (permalink / raw)
  To: pantelis.antoniou, robh+dt, frowand.list, grant.likely,
	devicetree, linux-kernel
  Cc: julia.lawall

for_each_child_of_node performs an of_node_get on each iteration, so
to break out of the loop an of_node_put is required.

Found using Coccinelle. The semantic patch used for this is as follows:

// <smpl>
@@
expression e;
local idexpression n;
@@

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

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/of/resolver.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 640eb4c..e2a0143 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -40,8 +40,10 @@ static struct device_node *__of_find_node_by_full_name(struct device_node *node,
 
 	for_each_child_of_node(node, child) {
 		found = __of_find_node_by_full_name(child, full_name);
-		if (found != NULL)
+		if (found != NULL) {
+			of_node_put(child);
 			return found;
+		}
 	}
 
 	return NULL;
-- 
1.9.1

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

end of thread, other threads:[~2016-01-29 23:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-27 15:20 [PATCH] of: resolver: Add missing of_node_put Amitoj Kaur Chawla
2016-01-27 16:05 ` Mark Rutland
2016-01-27 16:14   ` Pantelis Antoniou
2016-01-27 16:21     ` Mark Rutland
2016-01-27 18:02       ` Pantelis Antoniou
2016-01-27 19:48         ` Julia Lawall
2016-01-28 11:28           ` Mark Rutland
2016-01-28 11:36             ` Julia Lawall
2016-01-27 22:32         ` Julia Lawall
2016-01-29 16:45     ` Rob Herring
2016-01-29 17:33       ` Pantelis Antoniou
2016-01-29 23:46         ` Frank Rowand

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