get_node_by_path bug

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



Hello dtc developers,

My apologies if this is the incorrect place for this, I'm new here.

With the following device tree, dtc fails to find the /foo/baz node:
$ cat broken.dts 
/dts-v1/;
/ {
    ref = <&{/foo/baz}>;
    food {
    };
    foo {
	baz {
	};
    };
};
$ dtc -I dts -O dtb -o broken.dtb broken.dts 
broken.dtb: ERROR (phandle_references): Reference to non-existent node or label "/foo/baz"

ERROR: Input tree has errors, aborting (use -f to force output)
$ dtc -v
Version: DTC 1.4.4-g9067ee4b

The issue is in get_node_by_path, where it recurses into a child node without properly checking that the path strings are equal. This change fixes the issue for me:

diff --git a/livetree.c b/livetree.c
index 3673de0..aecd278 100644
--- a/livetree.c
+++ b/livetree.c
@@ -478,7 +478,8 @@ struct node *get_node_by_path(struct node *tree, const char *path)
        p = strchr(path, '/');
 
        for_each_child(tree, child) {
-               if (p && strneq(path, child->name, p-path))
+               if (p && (strlen(child->name) == p-path) &&
+                               strneq(path, child->name, p-path))
                        return get_node_by_path(child, p+1);
                else if (!p && streq(path, child->name))
                        return child;

Let me know if there is a better place to submit bug reports, or if you need anything more from me.

Thanks,
Tim
��.n��������+%������w��{.n����z�{��z��^n�r������&��z�ޗ�zf���h���~����������_��+v���)ߣ�

[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux