[PATCH 1/2] Revert "of: fix handling of '/' in options for of_find_node_by_path()"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




This reverts commit 106937e8ccdc
("of: fix handling of '/' in options for of_find_node_by_path()")

This fix breaks handling of strings containing both ':' and '/'.

Signed-off-by: Leif Lindholm <leif.lindholm@xxxxxxxxxx>
Fixes: 106937e8ccdc
---
 drivers/of/base.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index adb8764..3b1aa08 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -714,17 +714,16 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent,
 						const char *path)
 {
 	struct device_node *child;
-	int len;
-	const char *end;
+	int len = strchrnul(path, '/') - path;
+	int term;
 
-	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))
@@ -769,12 +768,8 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt
 
 	/* The path could begin with an alias */
 	if (*path != '/') {
-		int len;
-		const char *p = separator;
-
-		if (!p)
-			p = strchrnul(path, '/');
-		len = p - path;
+		char *p = strchrnul(path, '/');
+		int len = separator ? separator - path : p - path;
 
 		/* of_aliases must not be NULL */
 		if (!of_aliases)
@@ -799,8 +794,6 @@ 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

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux