[PATCH 1/3] OF: base: fix infinite loop in of_find_node_by_name
Sebastian Hesselbarth
sebastian.hesselbarth at gmail.com
Wed Jul 3 18:46:16 EDT 2013
of_find_node_by_name suffers from infinite looping, because it
does not check for root node of the tree iterated over. This adds a
check for parent pointer of last tested iterator entry, which is
NULL for the root node.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth at gmail.com>
---
Cc: barebox at lists.infradead.org
Cc: Hiroki Nishimoto <hiroki.nishimoto.if at gmail.com>
---
drivers/of/base.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index f21476c..df71e8c 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -301,9 +301,13 @@ struct device_node *of_find_node_by_name(struct device_node *from,
if (!from)
from = root_node;
- of_tree_for_each_node(np, from)
+ of_tree_for_each_node(np, from) {
if (np->name && !of_node_cmp(np->name, name))
return np;
+ /* check for root node */
+ if (!np->parent)
+ break;
+ }
return NULL;
}
--
1.7.10.4
More information about the barebox
mailing list