[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8e96f2d7-8ad1-47c9-ba12-49761edb8600@icloud.com>
Date: Mon, 9 Dec 2024 21:31:37 +0800
From: Zijun Hu <zijun_hu@...oud.com>
To: Rob Herring <robh@...nel.org>
Cc: 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>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, Zijun Hu <quic_zijuhu@...cinc.com>,
stable@...r.kernel.org
Subject: Re: [PATCH 01/10] of: Fix alias name length calculating error in API
of_find_node_opts_by_path()
On 2024/12/9 21:24, Rob Herring wrote:
> On Thu, Dec 5, 2024 at 6:53 PM Zijun Hu <zijun_hu@...oud.com> wrote:
>>
>> 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.
>
> Can you add a test case in the unittest for this.
sure. let me try to do it.
>
>>
>> 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