Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

of: fix handling of '/' in options for of_find_node_by_path()

Ensure proper handling of paths with appended options (after ':'),
where those options may contain a '/'.

Fixes: 7914a7c5651a ("of: support passing console options with stdout-path")
Reported-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
Cc: <stable@vger.kernel.org> # 3.19
Signed-off-by: Rob Herring <robh@kernel.org>

authored by

Leif Lindholm and committed by
Rob Herring
106937e8 649022e0

+15 -8
+15 -8
drivers/of/base.c
··· 714 714 const char *path) 715 715 { 716 716 struct device_node *child; 717 - int len = strchrnul(path, '/') - path; 718 - int term; 717 + int len; 718 + const char *end; 719 719 720 + end = strchr(path, ':'); 721 + if (!end) 722 + end = strchrnul(path, '/'); 723 + 724 + len = end - path; 720 725 if (!len) 721 726 return NULL; 722 - 723 - term = strchrnul(path, ':') - path; 724 - if (term < len) 725 - len = term; 726 727 727 728 __for_each_child_of_node(parent, child) { 728 729 const char *name = strrchr(child->full_name, '/'); ··· 769 768 770 769 /* The path could begin with an alias */ 771 770 if (*path != '/') { 772 - char *p = strchrnul(path, '/'); 773 - int len = separator ? separator - path : p - path; 771 + int len; 772 + const char *p = separator; 773 + 774 + if (!p) 775 + p = strchrnul(path, '/'); 776 + len = p - path; 774 777 775 778 /* of_aliases must not be NULL */ 776 779 if (!of_aliases) ··· 799 794 path++; /* Increment past '/' delimiter */ 800 795 np = __of_find_node_by_path(np, path); 801 796 path = strchrnul(path, '/'); 797 + if (separator && separator < path) 798 + break; 802 799 } 803 800 raw_spin_unlock_irqrestore(&devtree_lock, flags); 804 801 return np;