[PATCH 2/4] dm: core: fix wrong strlen check in of_add_subnode
Peng Fan (OSS)
peng.fan at oss.nxp.com
Fri Jul 3 11:11:25 CEST 2026
From: Peng Fan <peng.fan at nxp.com>
The duplicate-name check uses strlen on the search name instead of the
child name, so a child named "trevor" would falsely match a search
for "trev". Fix by checking strlen of child->name.
Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
drivers/core/of_access.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c
index 969492aae37..f910cc9a31b 100644
--- a/drivers/core/of_access.c
+++ b/drivers/core/of_access.c
@@ -1071,7 +1071,7 @@ int of_add_subnode(struct device_node *parent, const char *name, int len,
* make sure we don't use a child called "trevor" when we are
* searching for "trev".
*/
- if (!strncmp(child->name, name, len) && strlen(name) == len) {
+ if (!strncmp(child->name, name, len) && strlen(child->name) == len) {
*childp = child;
return -EEXIST;
}
--
2.51.0
More information about the U-Boot
mailing list