Re: [PATCH 1/2] USB: ehci-platform: fix companion-device leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>     # 4.11
> > Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx>
> > Signed-off-by: Johan Hovold <johan@xxxxxxxxxx>
> > ---
> >  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@xxxxxxxxxxx>

Thanks,
Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux