LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Rob Herring <robh@kernel.org>
Cc: Brian Norris <computersforpeace@gmail.com>,
	Peter Hurley <peter@hurleysoftware.com>,
	Leif Lindholm <leif.lindholm@linaro.org>,
	stable@vger.kernel.org, Grant Likely <grant.likely@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] of: handle both '/' and ':' in path strings
Date: Tue, 17 Mar 2015 12:30:31 -0700	[thread overview]
Message-ID: <1426620632-23383-1-git-send-email-computersforpeace@gmail.com> (raw)
In-Reply-To: <1425924225-22748-2-git-send-email-leif.lindholm@linaro.org>

Commit 106937e8ccdc ("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: 106937e8ccdc ("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
---
This is for -stable only because the regression is marked for stable. Not sure
the first one deserves to go to -stable, actually...

 drivers/of/base.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index adb8764861c0..966d6fdcf427 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -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;
 
-- 
1.9.1


  reply	other threads:[~2015-03-17 19:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-09 18:03 [PATCH 0/2] of: fix handling of '/' in path options Leif Lindholm
2015-03-09 18:03 ` [PATCH 1/2] of: fix handling of '/' in options for of_find_node_by_path() Leif Lindholm
2015-03-17 19:30   ` Brian Norris [this message]
2015-03-17 19:30     ` [PATCH 2/2] of: unittest: Add option string test case with longer path Brian Norris
2015-03-17 21:12       ` Leif Lindholm
2015-03-17 21:11     ` [PATCH 1/2] of: handle both '/' and ':' in path strings Leif Lindholm
2015-03-22 20:04     ` Rob Herring
2015-03-09 18:03 ` [PATCH 2/2] of: unittest: Add options string testcase variants Leif Lindholm
2015-03-11 12:49 ` [PATCH 0/2] of: fix handling of '/' in path options Rob Herring
2015-03-11 13:00   ` Leif Lindholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426620632-23383-1-git-send-email-computersforpeace@gmail.com \
    --to=computersforpeace@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=grant.likely@linaro.org \
    --cc=leif.lindholm@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter@hurleysoftware.com \
    --cc=robh+dt@kernel.org \
    --cc=robh@kernel.org \
    --cc=stable@vger.kernel.org \
    --subject='Re: [PATCH 1/2] of: handle both '\''/'\'' and '\'':'\'' in path strings' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).