[PATCH 4/5] of: Do not change property state under __of_add_property() failure

Zijun Hu posted 5 patches 9 months, 3 weeks ago
[PATCH 4/5] of: Do not change property state under __of_add_property() failure
Posted by Zijun Hu 9 months, 3 weeks ago
From: Zijun Hu <quic_zijuhu@quicinc.com>

Do not remove the property from list @np->deadprops if
__of_add_property() encounters -EEXIST failure.

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 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
Re: [PATCH 4/5] of: Do not change property state under __of_add_property() failure
Posted by Rob Herring 9 months, 3 weeks ago
On Mon, Feb 24, 2025 at 10:28:00PM +0800, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
> 
> Do not remove the property from list @np->deadprops if
> __of_add_property() encounters -EEXIST failure.

A property can never be on both np->deadprops and np->props.

> 
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
>  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
>
Re: [PATCH 4/5] of: Do not change property state under __of_add_property() failure
Posted by Zijun Hu 9 months, 3 weeks ago
On 2025/2/25 22:41, Rob Herring wrote:
> On Mon, Feb 24, 2025 at 10:28:00PM +0800, Zijun Hu wrote:
>> From: Zijun Hu <quic_zijuhu@quicinc.com>
>>
>> Do not remove the property from list @np->deadprops if
>> __of_add_property() encounters -EEXIST failure.
> A property can never be on both np->deadprops and np->props.

i made this patch based on convention that

partial task which has been done successfully needs to be undid if fails
to do the remaining task.

It is okay to drop this patch based on condition you mentioned.
thank you. (^^)(^^)
Re: [PATCH 4/5] of: Do not change property state under __of_add_property() failure
Posted by Zijun Hu 9 months, 3 weeks ago
On 2025/2/25 22:41, Rob Herring wrote:
> On Mon, Feb 24, 2025 at 10:28:00PM +0800, Zijun Hu wrote:
>> From: Zijun Hu <quic_zijuhu@quicinc.com>
>>
>> Do not remove the property from list @np->deadprops if
>> __of_add_property() encounters -EEXIST failure.
> A property can never be on both np->deadprops and np->props.

i made this patch based on convention that

This change is made base on convention that tasks which have
been done successfully needs to be undid if fails to do the
remaining task.


It is okay to drop this patch based on condition you mentioned.

thank you. (^^)(^^)