Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1320592

Re: [PATCH] of: resolver: Add missing of_node_put

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Julia Lawall <julia.lawall@lip6.fr>
Newsgroups linux.kernel
Subject Re: [PATCH] of: resolver: Add missing of_node_put
Date Thu, 28 Jan 2016 12:40:03 +0100
Message-ID <qVT5F-2Js-21@gated-at.bofh.it> (permalink)
References <qVAcG-5tw-21@gated-at.bofh.it> <qVAPo-65V-19@gated-at.bofh.it> <qVAZ4-6ax-15@gated-at.bofh.it> <qVB8L-6ft-23@gated-at.bofh.it> <qVCHv-7xR-1@gated-at.bofh.it> <qVEgl-6M-79@gated-at.bofh.it> <qVSVY-2EG-21@gated-at.bofh.it>
X-Original-To Mark Rutland <mark.rutland@arm.com>
X-Ironport-Av E=Sophos;i="5.22,358,1449529200"; d="scan'208";a="199864654"
X-X-Sender jll@hadrien
User-Agent Alpine 2.10 (DEB 1266 2009-07-14)
MIME-Version 1.0
Content-Type TEXT/PLAIN; charset=US-ASCII
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 64
Organization linux.* mail to news gateway
X-Original-Cc Pantelis Antoniou <pantelis.antoniou@konsulko.com>, Amitoj Kaur Chawla <amitoj1606@gmail.com>, Rob Herring <robh+dt@kernel.org>, Frank Rowand <frowand.list@gmail.com>, Grant Likely <grant.likely@linaro.org>, Devicetree List <devicetree@vger.kernel.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
X-Original-Date Thu, 28 Jan 2016 12:36:31 +0100 (CET)
X-Original-Message-ID <alpine.DEB.2.10.1601281235390.2516@hadrien>
X-Original-References <20160127152017.GA16048@amitoj-Inspiron-3542> <20160127160531.GB17123@leverpostej> <FE79FA58-A084-47BE-B872-7D57AC2B4D75@konsulko.com> <20160127162153.GC17123@leverpostej> <FF19B941-89E4-4954-9818-E352FE9A0E97@konsulko.com> <alpine.DEB.2.02.1601272042030.2051@localhost6.localdomain6> <20160128112810.GK17123@leverpostej>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1320592

Show key headers only | View raw



On Thu, 28 Jan 2016, Mark Rutland wrote:

> On Wed, Jan 27, 2016 at 08:48:00PM +0100, Julia Lawall wrote:
> >
> >
> > On Wed, 27 Jan 2016, Pantelis Antoniou wrote:
> >
> > > Hi Mark,
> > >
> > > > On Jan 27, 2016, at 18:21 , Mark Rutland <mark.rutland@arm.com> wrote:
> > > >
> > > > On Wed, Jan 27, 2016 at 06:14:00PM +0200, Pantelis Antoniou wrote:
> > > >> Hi Mark,
> > > >>
> > > >>> On Jan 27, 2016, at 18:05 , Mark Rutland <mark.rutland@arm.com> wrote:
> > > >>>
> > > >>> On Wed, Jan 27, 2016 at 08:50:17PM +0530, Amitoj Kaur Chawla wrote:
> > > >>>> diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
> > > >>>> index 640eb4c..e2a0143 100644
> > > >>>> --- a/drivers/of/resolver.c
> > > >>>> +++ b/drivers/of/resolver.c
> > > >>>> @@ -40,8 +40,10 @@ static struct device_node *__of_find_node_by_full_name(struct device_node *node,
> > > >>>>
> > > >>>> 	for_each_child_of_node(node, child) {
> > > >>>> 		found = __of_find_node_by_full_name(child, full_name);
> > > >>>> -		if (found != NULL)
> > > >>>> +		if (found != NULL) {
> > > >>>> +			of_node_put(child);
> > > >>>> 			return found;
> > > >>>> +		}
> > > >>>> 	}
> > > >>>>
> > > >>>> 	return NULL;
> > > >>>
> > > >>> I don't think this is quite right. When child == found, this change will
> > > >>> leave it decremented.
> > > >>>
> > > >>
> > > >>
> > > >> This patch is bogus.
> > > >>
> > > >> __of_find_node_by_full_name() is not taking a reference on the node if found.
> > > >> This method relies on keeping the reference taken by the loop.
> > > >
> > > > Sure. For the found node, that makes sense.
> > > >
> > > > However, it also increments the refcount of all the parents, which does
> > > > not seem correct to me, given they're not put on the return path, and a
> > > > put of the found node won't decrement its parents refcounts, unless I
> > > > have missed something.
> > > >
> > >
> > > Hmm, yes. The parent refcounts must be decremented.
> >
> > So there should be if (found != child) of_node_put(child); ?
>
> That would match the intended semantics, yes.

I don't think so.  I sent another mail with what seems like a better
solution (upping the reference count of the child that is selected).

julia

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [PATCH] of: resolver: Add missing of_node_put Mark Rutland <mark.rutland@arm.com> - 2016-01-28 12:30 +0100
  Re: [PATCH] of: resolver: Add missing of_node_put Julia Lawall <julia.lawall@lip6.fr> - 2016-01-28 12:40 +0100

csiph-web