ALSA: usb-audio: Fix double-free in error paths after snd_usb_add_audio_stream()...
authorVladis Dronov <vdronov@redhat.com>
Thu, 31 Mar 2016 16:05:43 +0000 (12:05 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 30 Apr 2016 22:05:22 +0000 (00:05 +0200)
commit7836b6be3ecf04a48076892e8dfa445e5349ad64
tree731912d56a2daf72f32fc7120aa48c0a8c524821
parentc26badfc853730dcf20820fd1d4f66fd0a2e6c92
ALSA: usb-audio: Fix double-free in error paths after snd_usb_add_audio_stream() call

commit 836b34a935abc91e13e63053d0a83b24dfb5ea78 upstream.

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>
Signed-off-by: Vladis Dronov <vdronov@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
sound/usb/quirks.c
sound/usb/stream.c