diff options
| author | Zijun Hu <quic_zijuhu@quicinc.com> | 2024-12-16 08:40:40 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-02-17 10:05:13 +0100 |
| commit | 4e4b3d4926734eb09edde556fb7977bdfa1256b3 (patch) | |
| tree | c6e8147f1cc4f3a031f92c75d98314ea2cfeaf47 /drivers/of | |
| parent | e62c630810202ee01d276a1982ecc7f59098d5ec (diff) | |
| download | linux-4e4b3d4926734eb09edde556fb7977bdfa1256b3.tar.gz linux-4e4b3d4926734eb09edde556fb7977bdfa1256b3.tar.bz2 linux-4e4b3d4926734eb09edde556fb7977bdfa1256b3.zip | |
of: Fix of_find_node_opts_by_path() handling of alias+path+options
commit b9e58c934c56aa35b0fb436d9afd86ef326bae0e upstream.
of_find_node_opts_by_path() fails to find OF device node when its
@path parameter have pattern below:
"alias-name/node-name-1/.../node-name-N:options".
The reason is that alias name length calculated by the API is wrong, as
explained by example below:
"testcase-alias/phandle-tests/consumer-a:testaliasoption".
^ ^ ^
0 14 39
The right length of alias 'testcase-alias' is 14, but the result worked
out by the API is 39 which is obvious wrong.
Fix by using index of either '/' or ':' as the length who comes earlier.
Fixes: 75c28c09af99 ("of: add optional options parameter to of_find_node_by_path()")
Cc: stable@vger.kernel.org
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20241216-of_core_fix-v2-1-e69b8f60da63@quicinc.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/of')
| -rw-r--r-- | drivers/of/base.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 2662174beba7..4bb87e0cbaf1 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -841,10 +841,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 */ |
