From: Zijun Hu <quic_zijuhu@quicinc.com>
__of_add_property() compares property name by strcmp(), and that is
improper for SPARC which wants strcasecmp().
Fix by using dedicated property name comparison macro of_prop_cmp().
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/of/base.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 001ff6ce4abf85c07f13649d5a9f691f549a8ccc..c810014957e81171675b63f25eaabe391cc903e4 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1651,7 +1651,7 @@ int __of_add_property(struct device_node *np, struct property *prop)
prop->next = NULL;
next = &np->properties;
while (*next) {
- if (strcmp(prop->name, (*next)->name) == 0) {
+ if (of_prop_cmp(prop->name, (*next)->name) == 0) {
/* duplicate ! don't insert it */
rc = -EEXIST;
goto out_unlock;
--
2.34.1
On Mon, Feb 24, 2025 at 10:27:59PM +0800, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
>
> __of_add_property() compares property name by strcmp(), and that is
> improper for SPARC which wants strcasecmp().
Except that 'name' is the nodename (usually, with a few rare
exceptions). Sparc node names are case sensitive, so strcmp was correct.
My hope is to get rid of case insensitive comparisions, so if nothing
cares that we're doing a case sensitive comparision, I want to keep
that.
I also want to get rid of storing both 'name' as a property and
device_node.name. The name property is an ABI issue though if no one is
looking, then it's not an ABI issue. Also, we should be able to generate
device_node.name from device_node.full_name. There's still a bunch of
direct users of device_node.name which have to be fixed. Mostly in clock
drivers from what I remember.
> Fix by using dedicated property name comparison macro of_prop_cmp().
>
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
> drivers/of/base.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 001ff6ce4abf85c07f13649d5a9f691f549a8ccc..c810014957e81171675b63f25eaabe391cc903e4 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -1651,7 +1651,7 @@ int __of_add_property(struct device_node *np, struct property *prop)
> prop->next = NULL;
> next = &np->properties;
> while (*next) {
> - if (strcmp(prop->name, (*next)->name) == 0) {
> + if (of_prop_cmp(prop->name, (*next)->name) == 0) {
> /* duplicate ! don't insert it */
> rc = -EEXIST;
> goto out_unlock;
>
> --
> 2.34.1
>
On 2025/2/25 22:38, Rob Herring wrote: > On Mon, Feb 24, 2025 at 10:27:59PM +0800, Zijun Hu wrote: >> From: Zijun Hu <quic_zijuhu@quicinc.com> >> >> __of_add_property() compares property name by strcmp(), and that is >> improper for SPARC which wants strcasecmp(). > Except that 'name' is the nodename (usually, with a few rare > exceptions). Sparc node names are case sensitive, so strcmp was correct. Here, it is property's name and NOT node's name. arch/sparc/include/asm/prom.h: #define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l)) #define of_prop_cmp(s1, s2) strcasecmp((s1), (s2)) //SPARC HERE #define of_node_cmp(s1, s2) strcmp((s1), (s2)) include/linux/of.h: /* Default string compare functions, Allow arch asm/prom.h to override */ #if !defined(of_compat_cmp) #define of_compat_cmp(s1, s2, l) strcasecmp((s1), (s2)) #define of_prop_cmp(s1, s2) strcmp((s1), (s2)) // others HERE #define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) #endif actually, later __of_update_property() and __of_find_property() use of_prop_cmp() instead of strcmp() to compare property name. perhaps, compatible and node name also have similar issues in current OF codes.
On Tue, Feb 25, 2025 at 11:04:55PM +0800, Zijun Hu wrote: > On 2025/2/25 22:38, Rob Herring wrote: > > On Mon, Feb 24, 2025 at 10:27:59PM +0800, Zijun Hu wrote: > >> From: Zijun Hu <quic_zijuhu@quicinc.com> > >> > >> __of_add_property() compares property name by strcmp(), and that is > >> improper for SPARC which wants strcasecmp(). > > Except that 'name' is the nodename (usually, with a few rare > > exceptions). Sparc node names are case sensitive, so strcmp was correct. > > Here, it is property's name and NOT node's name. Sigh, indeed... Applied. Rob
© 2016 - 2025 Red Hat, Inc.