* [PATCH 1/2] USB: ehci-platform: fix companion-device leak
@ 2017-05-16 14:26 Johan Hovold
2017-05-17 4:53 ` Yoshihiro Shimoda
0 siblings, 1 reply; 4+ messages in thread
From: Johan Hovold @ 2017-05-16 14:26 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Alan Stern, linux-usb, Johan Hovold, stable, Yoshihiro Shimoda
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);
+ }
ehci_resume(hcd, priv->reset_on_resume);
return 0;
--
2.13.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH 1/2] USB: ehci-platform: fix companion-device leak
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
0 siblings, 1 reply; 4+ messages in thread
From: Yoshihiro Shimoda @ 2017-05-17 4:53 UTC (permalink / raw)
To: Johan Hovold, Greg Kroah-Hartman; +Cc: Alan Stern, linux-usb, stable
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.
So,
Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Best regards,
Yoshihiro Shimoda
> ehci_resume(hcd, priv->reset_on_resume);
> return 0;
> --
> 2.13.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] USB: ehci-platform: fix companion-device leak
2017-05-17 4:53 ` Yoshihiro Shimoda
@ 2017-05-17 8:59 ` Johan Hovold
2017-05-18 1:50 ` Yoshihiro Shimoda
0 siblings, 1 reply; 4+ messages in thread
From: Johan Hovold @ 2017-05-17 8:59 UTC (permalink / raw)
To: Yoshihiro Shimoda
Cc: Johan Hovold, Greg Kroah-Hartman, Alan Stern, linux-usb, stable
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH 1/2] USB: ehci-platform: fix companion-device leak
2017-05-17 8:59 ` Johan Hovold
@ 2017-05-18 1:50 ` Yoshihiro Shimoda
0 siblings, 0 replies; 4+ messages in thread
From: Yoshihiro Shimoda @ 2017-05-18 1:50 UTC (permalink / raw)
To: Johan Hovold; +Cc: Greg Kroah-Hartman, Alan Stern, linux-usb, stable
Hi Johan,
> -----Original Message-----
> From: Johan Hovold
> Sent: Wednesday, May 17, 2017 6:00 PM
>
> 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.
Thank you for the reply!
I understood it and I agreed with you!
Best regards,
Yoshihiro Shimoda
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-18 1:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2017-05-18 1:50 ` Yoshihiro Shimoda
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.