summaryrefslogtreecommitdiff
path: root/sys/dev/ofw/fdt.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/ofw/fdt.c')
-rw-r--r--sys/dev/ofw/fdt.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/dev/ofw/fdt.c b/sys/dev/ofw/fdt.c
index c86df3e41d1..6810fdddfbc 100644
--- a/sys/dev/ofw/fdt.c
+++ b/sys/dev/ofw/fdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fdt.c,v 1.2 2016/03/07 10:49:03 mpi Exp $ */
+/* $OpenBSD: fdt.c,v 1.3 2016/03/17 14:10:29 mpi Exp $ */
/*
* Copyright (c) 2009 Dariusz Swiderski <sfires@sfires.net>
@@ -291,7 +291,7 @@ fdt_parent_node_recurse(void *pnode, void *child)
{
void *node = fdt_child_node(pnode);
void *tmp;
-
+
while (node && (node != child)) {
if ((tmp = fdt_parent_node_recurse(node, child)))
return tmp;
@@ -308,6 +308,9 @@ fdt_parent_node(void *node)
if (!tree_inited)
return NULL;
+ if (node == pnode)
+ return NULL;
+
return fdt_parent_node_recurse(pnode, node);
}
@@ -428,7 +431,7 @@ int
OF_parent(int handle)
{
void *node = (char *)tree.header + handle;
-
+
node = fdt_parent_node(node);
return node ? ((char *)node - (char *)tree.header) : 0;
}