From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751208AbdE3W4I (ORCPT ); Tue, 30 May 2017 18:56:08 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33895 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750970AbdE3W4G (ORCPT ); Tue, 30 May 2017 18:56:06 -0400 Subject: Re: [PATCH 1/7] USB: core: fix device node leak To: Johan Hovold , Greg Kroah-Hartman References: <20170530162554.26159-1-johan@kernel.org> <20170530162554.26159-2-johan@kernel.org> Cc: 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 From: Tyrel Datwyler Date: Tue, 30 May 2017 15:55:56 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170530162554.26159-2-johan@kernel.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17053022-0020-0000-0000-00000C0DB612 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007147; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000212; SDB=6.00867919; UDB=6.00431270; IPR=6.00647798; BA=6.00005387; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015652; XFM=3.00000015; UTC=2017-05-30 22:56:03 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17053022-0021-0000-0000-00005C904FD3 Message-Id: <9aff0d42-ff3e-963a-7aaa-752c2f592d0d@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-05-30_14:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705300416 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? 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. -Tyrel > usb_put_hcd(hcd); > kfree(udev->product); > kfree(udev->manufacturer); >