]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
dtc: livetree: fix get_node_by_path
authorSri Krishna chowdary <schowdary@nvidia.com>
Wed, 15 Jul 2015 06:09:10 +0000 (11:39 +0530)
committerIshan Mittal <imittal@nvidia.com>
Fri, 1 Apr 2016 05:07:19 +0000 (10:37 +0530)
Add check for length of child's name as well to avoid
path expanding into a different node than expected.

A path "/host1x/vic" can get us to non-existent node /host1x-pd/vic
if /host1x-pd/ comes before /host1x/

Bug 200105664

Change-Id: I1a32608a669e44249557e25b6575e5f95ac687cd
Signed-off-by: Sri Krishna chowdary <schowdary@nvidia.com>
Reviewed-on: http://git-master/r/770290
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: Sumit Singh <sumsingh@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
scripts/dtc/livetree.c

index e229b84432f99216189e92d6e61bc505aa4d6b9f..99f68ad1bed21b1ac7b36d3171e940fecc066619 100644 (file)
@@ -459,7 +459,9 @@ 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;