Commit 5f83b8d7 authored by Brian Norris's avatar Brian Norris Committed by Greg Kroah-Hartman

of: handle both '/' and ':' in path strings

commit 721a09e9 upstream.

Commit 106937e8 ("of: fix handling of '/' in options for
of_find_node_by_path()") caused a regression in OF handling of
stdout-path. While it fixes some cases which have '/' after the ':', it
breaks cases where there is more than one '/' *before* the ':'.

For example, it breaks this boot string

  stdout-path = "/rdb/serial@f040ab00:115200";

So rather than doing sequentialized checks (first for '/', then for ':';
or vice versa), to get the correct behavior we need to check for the
first occurrence of either one of them.

It so happens that the handy strcspn() helper can do just that.

Fixes: 106937e8 ("of: fix handling of '/' in options for of_find_node_by_path()")
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
Acked-by: default avatarLeif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8b78939b
......@@ -715,13 +715,8 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent,
{
struct device_node *child;
int len;
const char *end;
end = strchr(path, ':');
if (!end)
end = strchrnul(path, '/');
len = end - path;
len = strcspn(path, "/:");
if (!len)
return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment