mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 11:26:02 +09:00
USB: usb-skeleton: fix runtime PM after driver unbind
commit5c290a5e42upstream. Since commitc2b71462d2("USB: core: Fix bug caused by duplicate interface PM usage counter") USB drivers must always balance their runtime PM gets and puts, including when the driver has already been unbound from the interface. Leaving the interface with a positive PM usage counter would prevent a later bound driver from suspending the device. Fixes:c2b71462d2("USB: core: Fix bug caused by duplicate interface PM usage counter") Cc: stable <stable@vger.kernel.org> Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://lore.kernel.org/r/20191001084908.2003-2-johan@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
571a140636
commit
dcabc48fe0
@@ -71,6 +71,7 @@ static void skel_delete(struct kref *kref)
|
||||
struct usb_skel *dev = to_skel_dev(kref);
|
||||
|
||||
usb_free_urb(dev->bulk_in_urb);
|
||||
usb_put_intf(dev->interface);
|
||||
usb_put_dev(dev->udev);
|
||||
kfree(dev->bulk_in_buffer);
|
||||
kfree(dev);
|
||||
@@ -122,10 +123,7 @@ static int skel_release(struct inode *inode, struct file *file)
|
||||
return -ENODEV;
|
||||
|
||||
/* allow the device to be autosuspended */
|
||||
mutex_lock(&dev->io_mutex);
|
||||
if (dev->interface)
|
||||
usb_autopm_put_interface(dev->interface);
|
||||
mutex_unlock(&dev->io_mutex);
|
||||
usb_autopm_put_interface(dev->interface);
|
||||
|
||||
/* decrement the count on our device */
|
||||
kref_put(&dev->kref, skel_delete);
|
||||
@@ -505,7 +503,7 @@ static int skel_probe(struct usb_interface *interface,
|
||||
init_waitqueue_head(&dev->bulk_in_wait);
|
||||
|
||||
dev->udev = usb_get_dev(interface_to_usbdev(interface));
|
||||
dev->interface = interface;
|
||||
dev->interface = usb_get_intf(interface);
|
||||
|
||||
/* set up the endpoint information */
|
||||
/* use only the first bulk-in and bulk-out endpoints */
|
||||
|
||||
Reference in New Issue
Block a user