The changeset code checks for a property in the deadprops list when
adding/updating a property, but of_add_property() and
of_update_property() do not. As the users of these functions are pretty
simple, they have not hit this scenario or else the property lists
would get corrupted.
Signed-off-by: Rob Herring <robh@kernel.org>
---
drivers/of/base.c | 17 +++++++++++++++++
drivers/of/dynamic.c | 19 -------------------
2 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 166fb7d75337..99c07f3cbf10 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1538,6 +1538,14 @@ int __of_add_property(struct device_node *np, struct property *prop)
{
struct property **next;
+ /* If the property is in deadprops then it must be removed */
+ for (next = &np->deadprops; *next; next = &(*next)->next) {
+ if (*next == prop) {
+ *next = prop->next;
+ break;
+ }
+ }
+
prop->next = NULL;
next = &np->properties;
while (*next) {
@@ -1640,6 +1648,15 @@ int __of_update_property(struct device_node *np, struct property *newprop,
{
struct property **next, *oldprop;
+ /* If the property is in deadprops then it must be removed */
+ for (next = &np->deadprops; *next; next = &(*next)->next) {
+ if (*next == newprop) {
+ *next = newprop->next;
+ newprop->next = NULL;
+ break;
+ }
+ }
+
for (next = &np->properties; *next; next = &(*next)->next) {
if (of_prop_cmp((*next)->name, newprop->name) == 0)
break;
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 31603b5a4ffc..4fd3699691b6 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -565,7 +565,6 @@ static int __of_changeset_entry_notify(struct of_changeset_entry *ce,
static int __of_changeset_entry_apply(struct of_changeset_entry *ce)
{
- struct property **propp;
unsigned long flags;
int ret = 0;
@@ -581,15 +580,6 @@ static int __of_changeset_entry_apply(struct of_changeset_entry *ce)
__of_detach_node(ce->np);
break;
case OF_RECONFIG_ADD_PROPERTY:
- /* If the property is in deadprops then it must be removed */
- for (propp = &ce->np->deadprops; *propp; propp = &(*propp)->next) {
- if (*propp == ce->prop) {
- *propp = ce->prop->next;
- ce->prop->next = NULL;
- break;
- }
- }
-
ret = __of_add_property(ce->np, ce->prop);
break;
case OF_RECONFIG_REMOVE_PROPERTY:
@@ -597,15 +587,6 @@ static int __of_changeset_entry_apply(struct of_changeset_entry *ce)
break;
case OF_RECONFIG_UPDATE_PROPERTY:
- /* If the property is in deadprops then it must be removed */
- for (propp = &ce->np->deadprops; *propp; propp = &(*propp)->next) {
- if (*propp == ce->prop) {
- *propp = ce->prop->next;
- ce->prop->next = NULL;
- break;
- }
- }
-
ret = __of_update_property(ce->np, ce->prop, &ce->old_prop);
break;
default:
--
2.40.1
On Tue, Aug 01, 2023 at 03:54:47PM -0600, Rob Herring wrote: > The changeset code checks for a property in the deadprops list when > adding/updating a property, but of_add_property() and > of_update_property() do not. As the users of these functions are pretty > simple, they have not hit this scenario or else the property lists > would get corrupted. ... Seems like this... > + /* If the property is in deadprops then it must be removed */ > + for (next = &np->deadprops; *next; next = &(*next)->next) { > + if (*next == prop) { > + *next = prop->next; > + break; > + } > + } > prop->next = NULL; ... > + for (next = &np->deadprops; *next; next = &(*next)->next) { > + if (*next == newprop) { > + *next = newprop->next; > + newprop->next = NULL; > + break; > + } > + } ...is a dup of this. Are you planing to have a helper or at least conditional for_each_*() macro for them? -- With Best Regards, Andy Shevchenko
On Wed, Aug 2, 2023 at 9:12 AM Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > > On Tue, Aug 01, 2023 at 03:54:47PM -0600, Rob Herring wrote: > > The changeset code checks for a property in the deadprops list when > > adding/updating a property, but of_add_property() and > > of_update_property() do not. As the users of these functions are pretty > > simple, they have not hit this scenario or else the property lists > > would get corrupted. > > ... > > Seems like this... > > > + /* If the property is in deadprops then it must be removed */ > > + for (next = &np->deadprops; *next; next = &(*next)->next) { > > + if (*next == prop) { > > + *next = prop->next; > > + break; > > + } > > + } > > > prop->next = NULL; > > ... > > > + for (next = &np->deadprops; *next; next = &(*next)->next) { > > + if (*next == newprop) { > > + *next = newprop->next; > > + newprop->next = NULL; > > + break; > > + } > > + } > > ...is a dup of this. Are you planing to have a helper or at least conditional > for_each_*() macro for them? At least the latter would be more clean-up than I want to do here because this will be backported to stable. We have an iterator for properties list, but note how this iterates on the "next" ptr address. So it's a bit different from the normal iterators. I'll go ahead and add a helper. Rob
© 2016 - 2025 Red Hat, Inc.