From: Peng Fan <[email protected]> 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 <[email protected]> --- 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

