[PATCH 4/5] of: Do not change property state under __of_add_property() failure
From: Zijun Hu
Date: Mon Feb 24 2025 - 09:36:57 EST
From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
Do not remove the property from list @np->deadprops if
__of_add_property() encounters -EEXIST failure.
Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
---
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 c810014957e81171675b63f25eaabe391cc903e4..47cae6e48a48a7e1312c25fc5267bcf39102bbe9 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1646,9 +1646,6 @@ int __of_add_property(struct device_node *np, struct property *prop)
raw_spin_lock_irqsave(&devtree_lock, flags);
- __of_remove_property_from_list(&np->deadprops, prop);
-
- prop->next = NULL;
next = &np->properties;
while (*next) {
if (of_prop_cmp(prop->name, (*next)->name) == 0) {
@@ -1660,6 +1657,9 @@ int __of_add_property(struct device_node *np, struct property *prop)
}
*next = prop;
+ __of_remove_property_from_list(&np->deadprops, prop);
+ prop->next = NULL;
+
out_unlock:
raw_spin_unlock_irqrestore(&devtree_lock, flags);
if (rc)
--
2.34.1