USB: ehci-platform: fix companion-device leak
Subsystems (3)
PATCH 1/2 USB: ehci-platform: fix companion-device leak
Make sure do drop the reference taken to the companion device during resume.
--- drivers/usb/host/ehci-platform.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/host/ehci-platform.c +3 -1
@@ -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 ;
Signature · 1 line
2.13.0
Hi Johan,
Quoted 19 lines
From: Johan Hovold
Sent: Tuesday, May 16, 2017 11:26 PMMake 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 <[email protected]> # 4.11Cc Yoshihiro Shimoda <[email protected]>Signed-off-by Johan Hovold <[email protected]>--- drivers/usb/host/ehci-platform.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/usb/host/ehci-platform.c +0
-0
drivers/usb/host/ehci-platform.c static int ehci_platform_resume(struct device *dev) · line 389
Quoted 7 lines
drivers/usb/host/ehci-platform.c +2
-1@@ -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,
Best regards,
Yoshihiro Shimoda
Quoted 4 lines
drivers/usb/host/ehci-platform.c +0
-1ehci_resume (hcd, priv->reset_on_resume);return 0 ; --2.13.0
Quoted 31 lines · Yoshihiro Shimoda
Hi Johan,
Quoted 19 lines
From: Johan Hovold
Sent: Tuesday, May 16, 2017 11:26 PMMake 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 <[email protected]> # 4.11Cc Yoshihiro Shimoda <[email protected]>Signed-off-by Johan Hovold <[email protected]>--- drivers/usb/host/ehci-platform.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/usb/host/ehci-platform.c +0
-0drivers/usb/host/ehci-platform.c static int ehci_platform_resume(struct device *dev) · line 389
Quoted 7 lines
drivers/usb/host/ehci-platform.c +2
-1@@ -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!
Quoted 4 lines
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 ofput_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.
Quoted 3 lines
So,
Thanks,
Johan
Hi Johan,
Quoted 41 lines
-----Original Message-----
From: Johan Hovold
Sent: Wednesday, May 17, 2017 6:00 PMQuoted 31 lines · Yoshihiro Shimoda
Hi Johan,
Quoted 19 lines
From: Johan Hovold
Sent: Tuesday, May 16, 2017 11:26 PMMake 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 <[email protected]> # 4.11Cc Yoshihiro Shimoda <[email protected]>Signed-off-by Johan Hovold <[email protected]>--- drivers/usb/host/ehci-platform.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/usb/host/ehci-platform.c +0
-0drivers/usb/host/ehci-platform.c static int ehci_platform_resume(struct device *dev) · line 389
Quoted 7 lines
drivers/usb/host/ehci-platform.c +2
-1@@ -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!
Quoted 4 lines
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 ofput_device(). But, adding new API is not good for stable.
Quoted 6 lines
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