From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751405AbdKKPZQ (ORCPT ); Sat, 11 Nov 2017 10:25:16 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:44275 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750954AbdKKPZO (ORCPT ); Sat, 11 Nov 2017 10:25:14 -0500 X-Google-Smtp-Source: AGs4zMaXU6UT7FbjQDgFrwkFwFhyMAtxM6j9YqfT2cpjrfsiz6QCFrXLYkJrP3HsD5ezwly6evNVhw== Date: Sat, 11 Nov 2017 16:25:16 +0100 From: Johan Hovold To: Stephen Boyd Cc: Heikki Krogerus , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, Rob Clark , Peter Robinson Subject: Re: [PATCH] usb: ulpi: Add missing of_node_get() in ulpi_of_register() Message-ID: <20171111152516.GN11226@localhost> References: <20171111014300.2982-1-sboyd@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171111014300.2982-1-sboyd@codeaurora.org> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 10, 2017 at 05:43:00PM -0800, Stephen Boyd wrote: > In ulpi_of_register() we call of_find_node_by_name() which > unconditionally calls of_node_put() on the 'from' argument. We > haven't called of_node_get() though, so we've put the node once > without getting it first. Add the of_node_get() call so that > things are properly balanced. > > Fixes: ef6a7bcfb01c ("usb: ulpi: Support device discovery via DT") > Reported-by: Peter Robinson > Signed-off-by: Stephen Boyd > --- > drivers/usb/common/ulpi.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c > index 4aa5195db8ea..59e05eff76f9 100644 > --- a/drivers/usb/common/ulpi.c > +++ b/drivers/usb/common/ulpi.c > @@ -182,9 +182,9 @@ static int ulpi_of_register(struct ulpi *ulpi) > > /* Find a ulpi bus underneath the parent or the grandparent */ > parent = ulpi->dev.parent; > - if (parent->of_node) > + if (of_node_get(parent->of_node)) > np = of_find_node_by_name(parent->of_node, "ulpi"); > - else if (parent->parent && parent->parent->of_node) > + else if (parent->parent && of_node_get(parent->parent->of_node)) > np = of_find_node_by_name(parent->parent->of_node, "ulpi"); I'm afraid this isn't the right fix; the code shouldn't have been using of_find_node_by_name() in the first place as that function searches the whole device tree depth-first starting at the parent (or grand parent), which could end up matching an unrelated node. of_get_child_by_name() is the helper to use for such lookups instead. Turns out we have a few other driver with similar bugs. I've started fixing a few of them that'll be sending out per subsystem. I'll post a fix for this one as follow up to this mail meanwhile. Thanks, Johan