LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Leif Lindholm <leif.lindholm@linaro.org>
To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: grant.likely@linaro.org, robh+dt@kernel.org, peter@hurleysoftware.com
Subject: [PATCH 1/2] of: fix handling of '/' in options for of_find_node_by_path()
Date: Mon, 9 Mar 2015 18:03:44 +0000 [thread overview]
Message-ID: <1425924225-22748-2-git-send-email-leif.lindholm@linaro.org> (raw)
In-Reply-To: <1425924225-22748-1-git-send-email-leif.lindholm@linaro.org>
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>
---
drivers/of/base.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 0a8aeb8..8b904e5 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,
const char *path)
{
struct device_node *child;
- int len = strchrnul(path, '/') - path;
- int term;
+ int len;
+ const char *end;
+ end = strchr(path, ':');
+ if (!end)
+ end = strchrnul(path, '/');
+
+ len = end - path;
if (!len)
return NULL;
- term = strchrnul(path, ':') - path;
- if (term < len)
- len = term;
-
__for_each_child_of_node(parent, child) {
const char *name = strrchr(child->full_name, '/');
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
/* The path could begin with an alias */
if (*path != '/') {
- char *p = strchrnul(path, '/');
- int len = separator ? separator - path : p - path;
+ int len;
+ const char *p = separator;
+
+ if (!p)
+ p = strchrnul(path, '/');
+ len = p - path;
/* of_aliases must not be NULL */
if (!of_aliases)
@@ -794,6 +799,8 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt
path++; /* Increment past '/' delimiter */
np = __of_find_node_by_path(np, path);
path = strchrnul(path, '/');
+ if (separator && separator < path)
+ break;
}
raw_spin_unlock_irqrestore(&devtree_lock, flags);
return np;
--
2.1.4
next prev parent reply other threads:[~2015-03-09 18:02 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 ` Leif Lindholm [this message]
2015-03-17 19:30 ` [PATCH 1/2] of: handle both '/' and ':' in path strings Brian Norris
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=1425924225-22748-2-git-send-email-leif.lindholm@linaro.org \
--to=leif.lindholm@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peter@hurleysoftware.com \
--cc=robh+dt@kernel.org \
--subject='Re: [PATCH 1/2] of: fix handling of '\''/'\'' in options for of_find_node_by_path()' \
/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).