From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com ([74.125.82.66]:33792 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752437AbdEQI7n (ORCPT ); Wed, 17 May 2017 04:59:43 -0400 Date: Wed, 17 May 2017 10:59:41 +0200 From: Johan Hovold To: Yoshihiro Shimoda Cc: Johan Hovold , Greg Kroah-Hartman , Alan Stern , "linux-usb@vger.kernel.org" , stable Subject: Re: [PATCH 1/2] USB: ehci-platform: fix companion-device leak Message-ID: <20170517085941.GS3657@localhost> References: <20170516142614.15557-1-johan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: stable-owner@vger.kernel.org List-ID: On Wed, May 17, 2017 at 04:53:07AM +0000, Yoshihiro Shimoda wrote: > Hi Johan, > > > From: Johan Hovold > > Sent: Tuesday, May 16, 2017 11:26 PM > > > > Make sure do drop the reference taken to the companion device during > > resume. > > > > Fixes: d4d75128b8fd ("usb: host: ehci-platform: fix usb 1.1 device is not connected in system resume") > > Cc: stable # 4.11 > > Cc: Yoshihiro Shimoda > > Signed-off-by: Johan Hovold > > --- > > drivers/usb/host/ehci-platform.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c > > index bc7b9be12f54..f1908ea9fbd8 100644 > > --- a/drivers/usb/host/ehci-platform.c > > +++ b/drivers/usb/host/ehci-platform.c > > @@ -384,8 +384,10 @@ static int ehci_platform_resume(struct device *dev) > > } > > > > companion_dev = usb_of_get_companion_dev(hcd->self.controller); > > - if (companion_dev) > > + if (companion_dev) { > > device_pm_wait_for_dev(hcd->self.controller, companion_dev); > > + put_device(companion_dev); > > Thank you for the patch! > > I should have added an API like "usb_of_put_companion_dev(dev)" > and it calls "of_dev_put(to_platform_device(dev))". And then, > ehci_platform_resume() can call the API instead of put_device(). > But, adding new API is not good for stable. I don't think that's needed or desirable. The helper returns a pointer to a struct device with an incremented refcount, so just using put_device() when done is the right thing to do. Note that I added a comment about the refcount to the helper in patch 2/2 as a reminder for any future users. > So, > > Acked-by: Yoshihiro Shimoda Thanks, Johan