summaryrefslogtreecommitdiff
path: root/libfdt/fdt.c
diff options
context:
space:
mode:
Diffstat (limited to 'libfdt/fdt.c')
-rw-r--r--libfdt/fdt.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libfdt/fdt.c b/libfdt/fdt.c
index a59a518..940cee8 100644
--- a/libfdt/fdt.c
+++ b/libfdt/fdt.c
@@ -166,8 +166,8 @@ int fdt_next_node(const void *fdt, int offset, int *depth)
break;
case FDT_END_NODE:
- if (depth)
- (*depth)--;
+ if (depth && ((--(*depth)) < 0))
+ return nextoffset;
break;
case FDT_END: