[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241206-of_core_fix-v1-1-dc28ed56bec3@quicinc.com>
Date: Fri, 06 Dec 2024 08:52:27 +0800
From: Zijun Hu <zijun_hu@...oud.com>
To: Rob Herring <robh@...nel.org>, Saravana Kannan <saravanak@...gle.com>,
Leif Lindholm <leif.lindholm@...aro.org>,
Stephen Boyd <stephen.boyd@...aro.org>, Maxime Ripard <mripard@...nel.org>,
Robin Murphy <robin.murphy@....com>,
Grant Likely <grant.likely@...retlab.ca>
Cc: Zijun Hu <zijun_hu@...oud.com>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, Zijun Hu <quic_zijuhu@...cinc.com>,
stable@...r.kernel.org
Subject: [PATCH 01/10] of: Fix alias name length calculating error in API
of_find_node_opts_by_path()
From: Zijun Hu <quic_zijuhu@...cinc.com>
Alias name length calculated by of_find_node_opts_by_path() is wrong as
explained below:
Take "alias/serial@...500:115200n8" as its @patch argument for an example
^ ^ ^
0 5 19
The right length of alias 'alias' is 5, but the API results in 19 which is
obvious wrong.
The wrong length will cause finding device node failure for such paths.
Fix by using index of either '/' or ':' as the length who comes earlier.
Fixes: 106937e8ccdc ("of: fix handling of '/' in options for of_find_node_by_path()")
Cc: stable@...r.kernel.org
Signed-off-by: Zijun Hu <quic_zijuhu@...cinc.com>
---
drivers/of/base.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 7dc394255a0a14cd1aed02ec79c2f787a222b44c..9a9313183d1f1b61918fe7e6fa80c2726b099a1c 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -893,10 +893,10 @@ 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;
+ const char *p = strchrnul(path, '/');
- if (!p)
- p = strchrnul(path, '/');
+ if (separator && separator < p)
+ p = separator;
len = p - path;
/* of_aliases must not be NULL */
--
2.34.1
Powered by blists - more mailing lists