All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>,
	Grant Likely <grant.likely@linaro.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linux-omap <linux-omap@vger.kernel.org>,
	Mark Brown <broonie@kernel.org>, Takashi Iwai <tiwai@suse.com>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
	Linux-ALSA <alsa-devel@alsa-project.org>
Subject: Re: [PATCH] device property: Fix usecount for of_graph_get_port_parent()
Date: Thu, 27 Jul 2017 23:01:27 -0700	[thread overview]
Message-ID: <20170728060127.GH10026@atomide.com> (raw)
In-Reply-To: <CAL_JsqJ9Xmbws8gBRCxn2Nt=tj1HLnF-MGvnW+oOourvgbm9Nw@mail.gmail.com>

* Rob Herring <robh+dt@kernel.org> [170727 15:19]:
> On Thu, Jul 27, 2017 at 4:44 AM, Tony Lindgren <tony@atomide.com> 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:

struct device_node *of_graph_get_remote_port_parent(
		const struct device_node *node)
{
	struct device_node *np, *pp;

	/* Get remote endpoint node. */
	np = of_graph_get_remote_endpoint(node);

	pp = of_graph_get_port_parent(np);
	of_node_put(np);

	return pp;
}
EXPORT_SYMBOL(of_graph_get_remote_port_parent);

Does that make sense to you?

> > diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
> > --- a/sound/soc/generic/audio-graph-card.c
> > +++ b/sound/soc/generic/audio-graph-card.c
> > @@ -224,7 +224,6 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv)
> >
> >         of_for_each_phandle(&it, rc, node, "dais", NULL, 0) {
> >                 ret = asoc_graph_card_dai_link_of(it.node, priv, idx++);
> > -               of_node_put(it.node);
> >                 if (ret < 0)
> >                         return ret;
> 
> I think you need a put here.

Do you mean on error it should be as below, right?

	ret = asoc_graph_card_dai_link_of(it.node, priv, idx++);
	if (ret < 0) {
		of_node_put(it.node);
		return ret;
	}

Regards,

Tony

  reply	other threads:[~2017-07-28  6:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-27  9:44 [PATCH] device property: Fix usecount for of_graph_get_port_parent() Tony Lindgren
2017-07-27 16:17 ` Mark Brown
     [not found] ` <20170727094405.19778-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2017-07-27 22:18   ` Rob Herring
2017-07-27 22:18     ` Rob Herring
2017-07-28  6:01     ` Tony Lindgren [this message]
     [not found]       ` <20170728060127.GH10026-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2017-07-28  8:23         ` Tony Lindgren
2017-07-28  8:23           ` Tony Lindgren
     [not found]           ` <20170728082315.GL10026-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2017-07-28 22:58             ` Rob Herring
2017-07-28 22:58               ` Rob Herring
2017-07-30 20:31             ` Antonio Borneo
2017-07-30 20:31               ` Antonio Borneo
2017-07-31  0:55             ` [PATCH] " Kuninori Morimoto
2017-07-31  0:55               ` Kuninori Morimoto
2017-08-01 14:15           ` Mark Brown
2017-08-01 14:16           ` Applied "device property: Fix usecount for of_graph_get_port_parent()" to the asoc tree Mark Brown
2017-08-01 14:16             ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170728060127.GH10026@atomide.com \
    --to=tony@atomide.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=grant.likely@linaro.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.