This function is supposed to return NULL if the node isn't found.  But
the current implementation will always return the node for the last
path component that matched.  Wchis will be the root node if nothing
else matches.  So this function will never return NULL if the path
starts with '/'.  Diff fixes this issue.

ok?


Index: fdt.c
===================================================================
RCS file: /cvs/src/sys/dev/ofw/fdt.c,v
retrieving revision 1.18
diff -u -p -r1.18 fdt.c
--- fdt.c       26 Jul 2016 22:10:10 -0000      1.18
+++ fdt.c       23 Aug 2016 17:36:00 -0000
@@ -410,6 +410,9 @@ fdt_find_node(char *name)
                        }
                }
 
+               if (child == NULL)
+                       return NULL; /* No match found. */
+
                p = q;
        }
 

Reply via email to