[PATCH] OF: base: fix infinite loop in of_find_matching_node_and_match

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

 



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@xxxxxxxxx>
Reported-by: Hiroki Nishimoto <hiroki.nishimoto.if@xxxxxxxxx>
---
Cc: barebox@xxxxxxxxxxxxxxxxxxx
Cc: Hiroki Nishimoto <hiroki.nishimoto.if@xxxxxxxxx>
Cc: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 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


_______________________________________________
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