[PATCH 2/3] OF: base: fix infinite loop in of_find_compatible_node

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

 



of_find_compatible_node 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@xxxxxxxxx>
---
Cc: barebox@xxxxxxxxxxxxxxxxxxx
Cc: Hiroki Nishimoto <hiroki.nishimoto.if@xxxxxxxxx>
---
 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 df71e8c..25f2e96 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -335,9 +335,13 @@ struct device_node *of_find_compatible_node(struct device_node *from,
 	if (!from)
 		from = root_node;
 
-	of_tree_for_each_node(np, from)
+	of_tree_for_each_node(np, from) {
 		if (of_device_is_compatible(np, compatible))
 			return np;
+		/* check for root node */
+		if (!np->parent)
+			break;
+	}
 
 	return NULL;
 }
-- 
1.7.10.4


_______________________________________________
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