Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753258AbcDUWfV (ORCPT ); Thu, 21 Apr 2016 18:35:21 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:33530 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751681AbcDUWfT (ORCPT ); Thu, 21 Apr 2016 18:35:19 -0400 Message-ID: <571955A4.7080706@gmail.com> Date: Thu, 21 Apr 2016 15:35:16 -0700 From: Frank Rowand Reply-To: frowand.list@gmail.com User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Dmitry Torokhov CC: Rob Herring , Tony Lindgren , Scott Wood , Kumar Gala , Benjamin Herrenschmidt , Paul Mackerras , Arnd Bergmann , Grant Likely , Jingoo Han , Lee Jones , Jean-Christophe Plagniol-Villard , Tomi Valkeinen , "H. Nikolaus Schaller" , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [RFC/PATCH] of: of_find_node_by_name - stop dropping reference to 'from' node References: <20160419170540.GA8327@dtor-ws> In-Reply-To: <20160419170540.GA8327@dtor-ws> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2385 Lines: 62 On 4/19/2016 10:05 AM, Dmitry Torokhov wrote: > Majority of the callers of of_find_node_by_name() do not expect that it > will drop reference to the 'from' node if it was passed in, causing > potential refcount underflows, etc, so let's stop doing this. > > Most of the callers that were handling dropping of reference done by > of_find_node_by_name() actually wanted for_each_node_by_name() instead. > > Signed-off-by: Dmitry Torokhov > --- > > If this is acceptable I can make changes to other of_find_node_*() > methods... No. It is correct for of_find_by_name() to call of_node_put() for the from argument. The callers should be fixed. -Frank > > arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 2 ++ > arch/powerpc/platforms/83xx/mpc832x_mds.c | 2 +- > arch/powerpc/platforms/83xx/mpc832x_rdb.c | 2 +- > arch/powerpc/platforms/83xx/mpc836x_mds.c | 2 +- > arch/powerpc/platforms/cell/interrupt.c | 3 +-- > arch/powerpc/platforms/cell/setup.c | 3 +-- > arch/powerpc/platforms/cell/spider-pic.c | 3 +-- > arch/powerpc/platforms/powermac/feature.c | 2 +- > arch/powerpc/platforms/powermac/pic.c | 2 -- > drivers/input/misc/twl4030-vibra.c | 8 +------- > drivers/of/base.c | 3 +-- > drivers/pci/hotplug/rpadlpar_core.c | 4 ++-- > drivers/video/backlight/tps65217_bl.c | 4 ++-- > include/linux/of.h | 12 +++++++++--- > 14 files changed, 24 insertions(+), 28 deletions(-) < snip > > diff --git a/drivers/of/base.c b/drivers/of/base.c > index b299de2..45fc458 100644 > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -826,7 +826,7 @@ EXPORT_SYMBOL(of_find_node_opts_by_path); > * @from: The node to start searching from or NULL, the node > * you pass will not be searched, only the next one > * will; typically, you pass what the previous call > - * returned. of_node_put() will be called on it > + * returned. > * @name: The name string to match against > * > * Returns a node pointer with refcount incremented, use > @@ -843,7 +843,6 @@ struct device_node *of_find_node_by_name(struct device_node *from, > if (np->name && (of_node_cmp(np->name, name) == 0) > && of_node_get(np)) > break; > - of_node_put(from); > raw_spin_unlock_irqrestore(&devtree_lock, flags); > return np; > } < snip >