From 364a1831678d96bcbcd425d8359dc8f32f6a839a Mon Sep 17 00:00:00 2001 From: Jonas Richardsen Date: Mon, 15 Apr 2024 14:26:04 +0200 Subject: of: do not copy properties if they already exist in the destination Currently `of_copy_property` copies the given property even if a property with the same name already exists on the destination node. This leads to kernel warnings about duplicate properties: ``` [ 0.014063] Duplicate name in chosen, renamed to "stdout-path#1" [ 0.014093] Duplicate name in chosen, renamed to "bootargs#1" [ 0.014119] Duplicate name in chosen, renamed to "phandle#1" [ 0.014197] Duplicate name in reserved-memory, renamed to "#address-cells#1" [ 0.014226] Duplicate name in reserved-memory, renamed to "#size-cells#1" [ 0.014252] Duplicate name in reserved-memory, renamed to "ranges#1" [ 0.014278] Duplicate name in reserved-memory, renamed to "phandle#1" ``` Therefore, the function was changed to return an error if the property already exists in the destination. The change does not cause any regressions, because the only usage of this function occurs within `arch/arm/boards/raspberry-pi/rpi-common.c` where the original behaviour of the function is obviously unintended. Signed-off-by: Jonas Richardsen Link: https://lore.barebox.org/20240415122757.327312-1-jonasrichardsen@emlix.com Signed-off-by: Sascha Hauer --- drivers/of/base.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index 9bd0cdaac2..f0d3574148 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2346,6 +2346,9 @@ struct property *of_copy_property(const struct device_node *src, if (!prop) return NULL; + if (of_property_present(dst, propname)) + return ERR_PTR(-EEXIST); + return of_new_property(dst, propname, of_property_get_value(prop), prop->length); } -- cgit v1.2.3