Skip to content

Commit

Permalink
of: handle both '/' and ':' in path strings
Browse files Browse the repository at this point in the history
Commit 106937e ("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: 106937e ("of: fix handling of '/' in options for of_find_node_by_path()")
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: stable@vger.kernel.org # 3.19
Acked-by: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Rob Herring <robh@kernel.org>
  • Loading branch information
Brian Norris authored and Rob Herring committed Mar 19, 2015
1 parent 5ca1b0d commit 721a09e
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions drivers/of/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 721a09e

Please sign in to comment.