diff options
| -rw-r--r-- | drivers/of/base.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 3b1aa08bf5f3..adb8764861c0 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
| @@ -714,16 +714,17 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent, | |||
| 714 | const char *path) | 714 | const char *path) |
| 715 | { | 715 | { |
| 716 | struct device_node *child; | 716 | struct device_node *child; |
| 717 | int len = strchrnul(path, '/') - path; | 717 | int len; |
| 718 | int term; | 718 | const char *end; |
| 719 | 719 | ||
| 720 | end = strchr(path, ':'); | ||
| 721 | if (!end) | ||
| 722 | end = strchrnul(path, '/'); | ||
| 723 | |||
| 724 | len = end - path; | ||
| 720 | if (!len) | 725 | if (!len) |
| 721 | return NULL; | 726 | return NULL; |
| 722 | 727 | ||
| 723 | term = strchrnul(path, ':') - path; | ||
| 724 | if (term < len) | ||
| 725 | len = term; | ||
| 726 | |||
| 727 | __for_each_child_of_node(parent, child) { | 728 | __for_each_child_of_node(parent, child) { |
| 728 | const char *name = strrchr(child->full_name, '/'); | 729 | const char *name = strrchr(child->full_name, '/'); |
| 729 | if (WARN(!name, "malformed device_node %s\n", child->full_name)) | 730 | if (WARN(!name, "malformed device_node %s\n", child->full_name)) |
| @@ -768,8 +769,12 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt | |||
| 768 | 769 | ||
| 769 | /* The path could begin with an alias */ | 770 | /* The path could begin with an alias */ |
| 770 | if (*path != '/') { | 771 | if (*path != '/') { |
| 771 | char *p = strchrnul(path, '/'); | 772 | int len; |
| 772 | int len = separator ? separator - path : p - path; | 773 | const char *p = separator; |
| 774 | |||
| 775 | if (!p) | ||
| 776 | p = strchrnul(path, '/'); | ||
| 777 | len = p - path; | ||
| 773 | 778 | ||
| 774 | /* of_aliases must not be NULL */ | 779 | /* of_aliases must not be NULL */ |
| 775 | if (!of_aliases) | 780 | if (!of_aliases) |
| @@ -794,6 +799,8 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt | |||
| 794 | path++; /* Increment past '/' delimiter */ | 799 | path++; /* Increment past '/' delimiter */ |
| 795 | np = __of_find_node_by_path(np, path); | 800 | np = __of_find_node_by_path(np, path); |
| 796 | path = strchrnul(path, '/'); | 801 | path = strchrnul(path, '/'); |
| 802 | if (separator && separator < path) | ||
| 803 | break; | ||
| 797 | } | 804 | } |
| 798 | raw_spin_unlock_irqrestore(&devtree_lock, flags); | 805 | raw_spin_unlock_irqrestore(&devtree_lock, flags); |
| 799 | return np; | 806 | return np; |
