Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751776AbdG1GBd (ORCPT ); Fri, 28 Jul 2017 02:01:33 -0400 Received: from muru.com ([72.249.23.125]:56168 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751754AbdG1GBb (ORCPT ); Fri, 28 Jul 2017 02:01:31 -0400 Date: Thu, 27 Jul 2017 23:01:27 -0700 From: Tony Lindgren To: Rob Herring Cc: Frank Rowand , Grant Likely , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , linux-omap , Mark Brown , Takashi Iwai , Kuninori Morimoto , Linux-ALSA Subject: Re: [PATCH] device property: Fix usecount for of_graph_get_port_parent() Message-ID: <20170728060127.GH10026@atomide.com> References: <20170727094405.19778-1-tony@atomide.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.3 (2017-05-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2042 Lines: 66 * Rob Herring [170727 15:19]: > On Thu, Jul 27, 2017 at 4:44 AM, Tony Lindgren 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