mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] of: use of_get_child_by_name() to find child node
@ 2020-04-14  9:06 Michael Tretter
  2020-04-14  9:13 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Tretter @ 2020-04-14  9:06 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum, Michael Tretter

After iterating the children of a node with for_each_child_of_node(),
the child node will never be NULL. If the node was not found,
overlay_child will always point to the first element in the list, which
might or might not be the node that was searched.

Use the of_get_child_by_name() helper function to find the child node
with the name, which does the right thing and returns NULL if the node
is not found.

Reported-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
 drivers/of/resolver.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 9107c1fbb68c..4f720cf860c2 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -160,9 +160,7 @@ static int adjust_local_phandle_references(struct device_node *local_fixups,
 	}
 
 	for_each_child_of_node(local_fixups, child) {
-		for_each_child_of_node(overlay, overlay_child)
-			if (!of_node_cmp(child->name, overlay_child->name))
-				break;
+		overlay_child = of_get_child_by_name(overlay, child->name);
 		if (!overlay_child)
 			return -EINVAL;
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2020-04-14  9:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14  9:06 [PATCH] of: use of_get_child_by_name() to find child node Michael Tretter
2020-04-14  9:13 ` Sascha Hauer

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