From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751477AbdEaIZu (ORCPT ); Wed, 31 May 2017 04:25:50 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:34417 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750992AbdEaIZq (ORCPT ); Wed, 31 May 2017 04:25:46 -0400 Date: Wed, 31 May 2017 10:25:47 +0200 From: Johan Hovold To: Tyrel Datwyler Cc: Johan Hovold , Greg Kroah-Hartman , Linus Walleij , Peter Chen , Rob Herring , Arnd Bergmann , Sricharan R , Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable , Peter Chen Subject: Re: [PATCH 1/7] USB: core: fix device node leak Message-ID: <20170531082547.GB6735@localhost> References: <20170530162554.26159-1-johan@kernel.org> <20170530162554.26159-2-johan@kernel.org> <9aff0d42-ff3e-963a-7aaa-752c2f592d0d@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9aff0d42-ff3e-963a-7aaa-752c2f592d0d@linux.vnet.ibm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 30, 2017 at 03:55:56PM -0700, Tyrel Datwyler wrote: > On 05/30/2017 09:25 AM, Johan Hovold wrote: > > Make sure to release any OF device-node reference taken when creating > > the USB device. > > > > Note that we currently do not hold a reference to the root hub > > device-tree node (i.e. the parent controller node). > > > > Fixes: 69bec7259853 ("USB: core: let USB device know device node") > > Cc: stable # v4.6 > > Cc: Peter Chen > > Signed-off-by: Johan Hovold > > --- > > drivers/usb/core/usb.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c > > index 28b053cacc90..62e1906bb2f3 100644 > > --- a/drivers/usb/core/usb.c > > +++ b/drivers/usb/core/usb.c > > @@ -416,6 +416,8 @@ static void usb_release_dev(struct device *dev) > > > > usb_destroy_configuration(udev); > > usb_release_bos_descriptor(udev); > > + if (udev->parent) > > + of_node_put(dev->of_node); > > If I'm following the root hub doesn't hold an of_node reference, so > does that guarantee that dev->of_node is NULL for the root hub? No, it may be non-NULL. > If so of_node_put() is safely called with a NULL reference, making the > if(udev->parent) unnecessary, and further no need to remove it in > follow-up patch #5. So this one is still needed. Thanks, Johan