Commit c5aa956e authored by Pavel Skripkin's avatar Pavel Skripkin Committed by Takashi Iwai

ALSA: usb-audio: fix use after free in usb_audio_disconnect

The problem was in wrong "if" placement. chip->quirk_type is freed
in snd_card_free_when_closed(), but inside if statement it's accesed.

Fixes: 97991108 ("ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()")
Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/16da19126ff461e5e64a9aec648cce28fb8ed73e.1615242183.git.paskripkin@gmail.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 30dea071
...@@ -907,6 +907,9 @@ static void usb_audio_disconnect(struct usb_interface *intf) ...@@ -907,6 +907,9 @@ static void usb_audio_disconnect(struct usb_interface *intf)
} }
} }
if (chip->quirk_type & QUIRK_SETUP_DISABLE_AUTOSUSPEND)
usb_enable_autosuspend(interface_to_usbdev(intf));
chip->num_interfaces--; chip->num_interfaces--;
if (chip->num_interfaces <= 0) { if (chip->num_interfaces <= 0) {
usb_chip[chip->index] = NULL; usb_chip[chip->index] = NULL;
...@@ -915,9 +918,6 @@ static void usb_audio_disconnect(struct usb_interface *intf) ...@@ -915,9 +918,6 @@ static void usb_audio_disconnect(struct usb_interface *intf)
} else { } else {
mutex_unlock(&register_mutex); mutex_unlock(&register_mutex);
} }
if (chip->quirk_type & QUIRK_SETUP_DISABLE_AUTOSUSPEND)
usb_enable_autosuspend(interface_to_usbdev(intf));
} }
/* lock the shutdown (disconnect) task and autoresume */ /* lock the shutdown (disconnect) task and autoresume */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment