[PATCH] of: use of_get_child_by_name() to find child node

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
Signed-off-by: Michael Tretter <m.tretter@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux