Skip to content

Commit

Permalink
ALSA: usb-audio: fix use after free in usb_audio_disconnect
Browse files Browse the repository at this point in the history
commit c5aa956 upstream.

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: 9799110 ("ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/16da19126ff461e5e64a9aec648cce28fb8ed73e.1615242183.git.paskripkin@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
pskrgag authored and gregkh committed Mar 17, 2021
1 parent d5fb0e4 commit 569c90d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sound/usb/card.c
Expand Up @@ -908,6 +908,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--;
if (chip->num_interfaces <= 0) {
usb_chip[chip->index] = NULL;
Expand All @@ -916,9 +919,6 @@ static void usb_audio_disconnect(struct usb_interface *intf)
} else {
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 */
Expand Down

0 comments on commit 569c90d

Please sign in to comment.