Re: [PATCH 4/5] of: Do not change property state under __of_add_property() failure
From: Rob Herring
Date: Tue Feb 25 2025 - 09:47:55 EST
On Mon, Feb 24, 2025 at 10:28:00PM +0800, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
>
> 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@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
>