[PATCH] OF: base: fix infinite loop in of_find_matching_node_and_match
Sebastian Hesselbarth
sebastian.hesselbarth at gmail.com
Wed Jul 3 17:59:32 EDT 2013
of_find_matching_node_and_match macro can loop infinitely, 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>
Reported-by: Hiroki Nishimoto <hiroki.nishimoto.if at gmail.com>
---
Cc: barebox at lists.infradead.org
Cc: Hiroki Nishimoto <hiroki.nishimoto.if at gmail.com>
Cc: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/of/base.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index e9f1f79..f21476c 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -418,6 +418,9 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from,
*match = m;
return np;
}
+ /* check for root node */
+ if (!np->parent)
+ break;
}
return NULL;
--
1.7.10.4
More information about the barebox
mailing list