Skip to content

Commit 0ef7436

Browse files
committed
ALSA: usb-audio: Add spinlock to stop_urbs()
In theory, stop_urbs() may be called concurrently. Although we have the state check beforehand, it's safer to apply ep->lock during the critical list head manipulations. Link: https://lore.kernel.org/r/20210929080844.11583-8-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent d215f63 commit 0ef7436

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sound/usb/endpoint.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,16 +927,19 @@ void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep)
927927
static int stop_urbs(struct snd_usb_endpoint *ep, bool force)
928928
{
929929
unsigned int i;
930+
unsigned long flags;
930931

931932
if (!force && atomic_read(&ep->running))
932933
return -EBUSY;
933934

934935
if (!ep_state_update(ep, EP_STATE_RUNNING, EP_STATE_STOPPING))
935936
return 0;
936937

938+
spin_lock_irqsave(&ep->lock, flags);
937939
INIT_LIST_HEAD(&ep->ready_playback_urbs);
938940
ep->next_packet_head = 0;
939941
ep->next_packet_queued = 0;
942+
spin_unlock_irqrestore(&ep->lock, flags);
940943

941944
for (i = 0; i < ep->nurbs; i++) {
942945
if (test_bit(i, &ep->active_mask)) {

0 commit comments

Comments
 (0)