stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: Johan Hovold <johan@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	stable <stable@vger.kernel.org>
Subject: Re: [PATCH 1/2] USB: ehci-platform: fix companion-device leak
Date: Wed, 17 May 2017 10:59:41 +0200	[thread overview]
Message-ID: <20170517085941.GS3657@localhost> (raw)
In-Reply-To: <TY1PR06MB0992EF3EEBB4843E23AC3A62D8E70@TY1PR06MB0992.apcprd06.prod.outlook.com>

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 <stable@vger.kernel.org>     # 4.11
> > Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > Signed-off-by: Johan Hovold <johan@kernel.org>
> > ---
> >  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 <yoshihiro.shimoda.uh@renesas.com>

Thanks,
Johan

  reply	other threads:[~2017-05-17  8:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-16 14:26 [PATCH 1/2] USB: ehci-platform: fix companion-device leak Johan Hovold
2017-05-17  4:53 ` Yoshihiro Shimoda
2017-05-17  8:59   ` Johan Hovold [this message]
2017-05-18  1:50     ` Yoshihiro Shimoda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170517085941.GS3657@localhost \
    --to=johan@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).