diff options
author | Michael Tretter <m.tretter@pengutronix.de> | 2020-04-14 11:06:10 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-04-14 11:12:42 +0200 |
commit | dac73d73d13c2100c42dc40e6568d72a027133de (patch) | |
tree | 4b3167fea6648c20f68af1a50c8f8c8361033350 /drivers/of | |
parent | 44e52238049cbf29a2f777a4aa1cc39f58ee353c (diff) | |
download | barebox-dac73d73d13c2100c42dc40e6568d72a027133de.tar.gz barebox-dac73d73d13c2100c42dc40e6568d72a027133de.tar.xz |
of: use of_get_child_by_name() to find child node
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>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/resolver.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c index 9107c1fbb6..4f720cf860 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; |