ALSA: usb-audio: Fix potential use-after-free of streams
diff mbox series

Message ID
State New
Headers show
  • ALSA: usb-audio: Fix potential use-after-free of streams
Related show

Commit Message

Takashi Iwai June 16, 2020, 12:09 p.m. UTC
With the recent full-duplex support of implicit feedback streams, an
endpoint can be still running after closing the capture stream as long
as the playback stream with the sync-endpoint is running.  In such a
state, the URBs are still be handled and they may call retire_data_urb
callback, which tries to transfer the data from the PCM buffer.  Since
the PCM stream gets closed, this may lead to use-after-free.

This patch adds the proper clearance of the callback at stopping the
capture stream for addressing the possible UAF above.

Fixes: 10ce77e4817f ("ALSA: usb-audio: Add duplex sound support for USB devices using implicit feedback")
Signed-off-by: Takashi Iwai <>
 sound/usb/pcm.c | 1 +
 1 file changed, 1 insertion(+)

diff mbox series

diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 84c0ae431936..a777d36c4f5a 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -1787,6 +1787,7 @@  static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream
 		return 0;
+		subs->data_endpoint->retire_data_urb = NULL;
 		subs->running = 0;
 		return 0;