Re: [PATCH] device property: Fix usecount for of_graph_get_port_parent()

From: Tony Lindgren
Date: Fri Jul 28 2017 - 04:23:27 EST


* Tony Lindgren <tony@xxxxxxxxxxx> [170727 23:02]:
> * Rob Herring <robh+dt@xxxxxxxxxx> [170727 15:19]:
> > On Thu, Jul 27, 2017 at 4:44 AM, Tony Lindgren <tony@xxxxxxxxxxx> wrote:
> > > --- a/drivers/of/property.c
> > > +++ b/drivers/of/property.c
> > > @@ -708,6 +708,15 @@ struct device_node *of_graph_get_port_parent(struct device_node *node)
> > > {
> > > unsigned int depth;
> > >
> > > + if (!node)
> > > + return NULL;
> > > +
> > > + /*
> > > + * Preserve usecount for passed in node as of_get_next_parent()
> > > + * will do of_node_put() on it.
> > > + */
> > > + of_node_get(node);
> >
> > I think this messes up of_graph_get_remote_port_parent(). First it
> > calls of_graph_get_remote_endpoint which returns the endpoint node
> > with ref count incremented. Then you are incrementing it again here.
>
> Hmm OK looks like I missed that one. If we want to have
> of_graph_get_port_parent not trash the node passed to it, we should
> just change things there too:

Found few more things to fix with git grep -C20 of_graph_get_port_parent,
below is v2.

Can you all prese review again and do some testing. I also fixed up
audio-graph-scu-card but can't test that one.

Regards,

Tony

8< ------