mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 17:30:02 +00:00
ALSA: usb-audio: Fix racy list management in output queue
The linked list entry from FIFO is peeked at
queue_pending_output_urbs() but the actual element pop-out is
performed outside the spinlock, and it's potentially racy.
Do delete the link at the right place inside the spinlock.
Fixes: 8fdff6a319
("ALSA: snd-usb: implement new endpoint streaming model")
Link: https://lore.kernel.org/r/20200424074016.14301-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
04c96460bf
commit
5b6cc38f3f
1 changed files with 3 additions and 3 deletions
|
@ -346,17 +346,17 @@ static void queue_pending_output_urbs(struct snd_usb_endpoint *ep)
|
||||||
ep->next_packet_read_pos %= MAX_URBS;
|
ep->next_packet_read_pos %= MAX_URBS;
|
||||||
|
|
||||||
/* take URB out of FIFO */
|
/* take URB out of FIFO */
|
||||||
if (!list_empty(&ep->ready_playback_urbs))
|
if (!list_empty(&ep->ready_playback_urbs)) {
|
||||||
ctx = list_first_entry(&ep->ready_playback_urbs,
|
ctx = list_first_entry(&ep->ready_playback_urbs,
|
||||||
struct snd_urb_ctx, ready_list);
|
struct snd_urb_ctx, ready_list);
|
||||||
|
list_del_init(&ctx->ready_list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&ep->lock, flags);
|
spin_unlock_irqrestore(&ep->lock, flags);
|
||||||
|
|
||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
list_del_init(&ctx->ready_list);
|
|
||||||
|
|
||||||
/* copy over the length information */
|
/* copy over the length information */
|
||||||
for (i = 0; i < packet->packets; i++)
|
for (i = 0; i < packet->packets; i++)
|
||||||
ctx->packet_size[i] = packet->packet_size[i];
|
ctx->packet_size[i] = packet->packet_size[i];
|
||||||
|
|
Loading…
Reference in a new issue