diff options
author | Takashi Iwai <tiwai@suse.de> | 2021-09-29 10:08:42 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-12-08 09:04:36 +0100 |
commit | 7303160785e5c7c07c302a30142e0cf737b61b36 (patch) | |
tree | ab44904310b00e8dbee1cae4d8f10453b7ed6669 /sound/usb | |
parent | 31056232ad3cc37d3a0fef928f292e57ea055a59 (diff) | |
download | linux-stable-7303160785e5c7c07c302a30142e0cf737b61b36.tar.gz linux-stable-7303160785e5c7c07c302a30142e0cf737b61b36.tar.bz2 linux-stable-7303160785e5c7c07c302a30142e0cf737b61b36.zip |
ALSA: usb-audio: Add spinlock to stop_urbs()
commit 0ef74366bc150dda4f53c546dfa6e8f7c707e087 upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/endpoint.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 1f757a7eeafe..c32022672319 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -927,6 +927,7 @@ void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep) static int stop_urbs(struct snd_usb_endpoint *ep, bool force) { unsigned int i; + unsigned long flags; if (!force && atomic_read(&ep->running)) return -EBUSY; @@ -934,9 +935,11 @@ static int stop_urbs(struct snd_usb_endpoint *ep, bool force) if (!ep_state_update(ep, EP_STATE_RUNNING, EP_STATE_STOPPING)) return 0; + spin_lock_irqsave(&ep->lock, flags); INIT_LIST_HEAD(&ep->ready_playback_urbs); ep->next_packet_head = 0; ep->next_packet_queued = 0; + spin_unlock_irqrestore(&ep->lock, flags); for (i = 0; i < ep->nurbs; i++) { if (test_bit(i, &ep->active_mask)) { |