UPSTREAM: ALSA: usb-audio: Fix double-free in error paths after snd_usb_add_audio_str...
authorVladis Dronov <vdronov@redhat.com>
Thu, 31 Mar 2016 16:05:43 +0000 (12:05 -0400)
committerMark Salyzyn <salyzyn@google.com>
Fri, 9 Sep 2016 21:23:43 +0000 (21:23 +0000)
commit571763be0e7f0aab3aa3eb02bb315b63539cc10c
tree9b70e1d93bdc69cc67594b7de5253d56bb562730
parent0f959e0a3261539eb14420d02a491188cc52f9e8
UPSTREAM: ALSA: usb-audio: Fix double-free in error paths after snd_usb_add_audio_stream() call

(cherry picked from commit 836b34a935abc91e13e63053d0a83b24dfb5ea78)

create_fixed_stream_quirk(), snd_usb_parse_audio_interface() and
create_uaxx_quirk() functions allocate the audioformat object by themselves
and free it upon error before returning. However, once the object is linked
to a stream, it's freed again in snd_usb_audio_pcm_free(), thus it'll be
double-freed, eventually resulting in a memory corruption.

This patch fixes these failures in the error paths by unlinking the audioformat
object before freeing it.

Based on a patch by Takashi Iwai <tiwai@suse.de>

[Note for stable backports:
 this patch requires the commit 902eb7fd1e4a ('ALSA: usb-audio: Minor
 code cleanup in create_fixed_stream_quirk()')]

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1283358
Reported-by: Ralf Spenneberg <ralf@spenneberg.net>
Cc: <stable@vger.kernel.org> # see the note above
Signed-off-by: Vladis Dronov <vdronov@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Change-Id: I7073a17d8c99886d2f6ed7981892712ba7dd5873
Bug: 30952477
sound/usb/quirks.c
sound/usb/stream.c