Re: [PATCH v4 5/6] of: implement of_move_node helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 13, 2023 at 10:30:10AM +0200, Ahmad Fatoum wrote:
> On 13.06.23 10:27, Sascha Hauer wrote:
> > On Mon, Jun 12, 2023 at 02:51:03PM +0200, Ahmad Fatoum wrote:
> >> Reparenting nodes can be a useful thing to do in fixups. Add a helper
> >> for that.
> >>
> >> Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
> >> ---
> >>  drivers/of/base.c | 18 ++++++++++++++++++
> >>  include/of.h      |  1 +
> >>  2 files changed, 19 insertions(+)
> >>
> >> diff --git a/drivers/of/base.c b/drivers/of/base.c
> >> index e3416b5b75a7..43a4a923d9c5 100644
> >> --- a/drivers/of/base.c
> >> +++ b/drivers/of/base.c
> >> @@ -2695,6 +2695,24 @@ void of_delete_node(struct device_node *node)
> >>  	free(node);
> >>  }
> >>  
> >> +void of_move_node(struct device_node *parent, struct device_node *node)
> >> +{
> >> +	if (!node)
> >> +		return;
> >> +
> >> +	list_del(&node->list);
> >> +	list_del(&node->parent_list);
> >> +
> >> +	free(node->full_name);
> >> +	node->full_name = basprintf("%s/%s", parent->full_name, node->name);
> >> +
> >> +	if (!node->parent)
> >> +		return;
> > 
> > Why is the old parent relevant here? Even when node didn't have a parent
> > before you should still add it to the children list of the new parent.
> > 
> > Also node->parent should be set to the new parent.
> > 
> > You seem to honour the case that node didn't have a parent previously.
> > Does the list_del(&node->parent_list) work in this case? I can't see any
> > INIT_LIST_HEAD(&node->parent_list) in the code, so I assume running a
> > list_del on it results in a NULL pointer dereference.
> 
> I will revisit this. Can you pick patches 1-4 though, so we can finally
> get this in?

Did that.

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux