Skip to content

Commit a3dbeb5

Browse files
committed
Revert "of: fix of_update_property()"
This reverts commit 02ed594. The change is completely broken. It attempt to get the previous item in a linked list by grabbing the address of a stack variable. Outright wrong. Signed-off-by: Grant Likely <[email protected]>
1 parent f4d4ffc commit a3dbeb5

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

drivers/of/base.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,7 +1597,7 @@ int of_update_property(struct device_node *np, struct property *newprop)
15971597
{
15981598
struct property **next, *oldprop;
15991599
unsigned long flags;
1600-
int rc = 0;
1600+
int rc, found = 0;
16011601

16021602
rc = of_property_notify(OF_RECONFIG_UPDATE_PROPERTY, np, newprop);
16031603
if (rc)
@@ -1606,28 +1606,36 @@ int of_update_property(struct device_node *np, struct property *newprop)
16061606
if (!newprop->name)
16071607
return -EINVAL;
16081608

1609+
oldprop = of_find_property(np, newprop->name, NULL);
1610+
if (!oldprop)
1611+
return of_add_property(np, newprop);
1612+
16091613
raw_spin_lock_irqsave(&devtree_lock, flags);
1610-
oldprop = __of_find_property(np, newprop->name, NULL);
1611-
if (!oldprop) {
1612-
/* add the node */
1613-
rc = __of_add_property(np, newprop);
1614-
} else {
1615-
/* replace the node */
1616-
next = &oldprop;
1617-
newprop->next = oldprop->next;
1618-
*next = newprop;
1619-
oldprop->next = np->deadprops;
1620-
np->deadprops = oldprop;
1614+
next = &np->properties;
1615+
while (*next) {
1616+
if (*next == oldprop) {
1617+
/* found the node */
1618+
newprop->next = oldprop->next;
1619+
*next = newprop;
1620+
oldprop->next = np->deadprops;
1621+
np->deadprops = oldprop;
1622+
found = 1;
1623+
break;
1624+
}
1625+
next = &(*next)->next;
16211626
}
16221627
raw_spin_unlock_irqrestore(&devtree_lock, flags);
16231628

1629+
if (!found)
1630+
return -ENODEV;
1631+
16241632
#ifdef CONFIG_PROC_DEVICETREE
16251633
/* try to add to proc as well if it was initialized */
16261634
if (!rc && np->pde)
16271635
proc_device_tree_update_prop(np->pde, newprop, oldprop);
16281636
#endif /* CONFIG_PROC_DEVICETREE */
16291637

1630-
return rc;
1638+
return 0;
16311639
}
16321640

16331641
#if defined(CONFIG_OF_DYNAMIC)

0 commit comments

Comments
 (0)