sound: usb: get lock before calling usb_enable_autosuspend()
PATCH 1/1 sound: usb: get lock before calling usb_enable_autosuspend()
Based on the documentation of usb_enable_autosuspend(), the caller must hold udev's device lock.
Signed-off-by Salah Triki <[email protected]>
--- sound/usb/card.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
sound/usb/card.c +7 -2
@@ -907,8 +907,13 @@ static void usb_audio_disconnect(struct usb_interface *intf) } } -if (chip->quirk_type &QUIRK_SETUP_DISABLE_AUTOSUSPEND ) -usb_enable_autosuspend (interface_to_usbdev (intf)); +if (chip->quirk_type &QUIRK_SETUP_DISABLE_AUTOSUSPEND ) { +struct usb_device *udev =interface_to_usbdev (intf); + +usb_lock_device (udev); +usb_enable_autosuspend (udev); +usb_unlock_device (udev); + } chip->num_interfaces--;if (chip->num_interfaces <=0 ) {
Signature · 1 line
2.25.1
Quoted 3 lines · Salah Triki
Based on the documentation of
usb_enable_autosuspend(), the caller must hold udev's device lock.
The device lock is already held in the caller side (in the driver core), hence this change will lead to a deadlock.
thanks,
Takashi
Quoted 29 lines
Signed-off-by Salah Triki <[email protected]>--- sound/usb/card.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)sound/usb/card.c +7
-2@@ -907,8 +907,13 @@ static void usb_audio_disconnect(struct usb_interface *intf) } } -if (chip->quirk_type &QUIRK_SETUP_DISABLE_AUTOSUSPEND ) -usb_enable_autosuspend (interface_to_usbdev (intf)); +if (chip->quirk_type &QUIRK_SETUP_DISABLE_AUTOSUSPEND ) { +struct usb_device *udev =interface_to_usbdev (intf); + +usb_lock_device (udev); +usb_enable_autosuspend (udev); +usb_unlock_device (udev); + } chip->num_interfaces--;if (chip->num_interfaces <=0 ) {Signature · 1 line
2.25.1