ALSA: bebob: change the range of critical section for stream data in PCM.hw_free...
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sat, 15 Jun 2019 09:10:58 +0000 (18:10 +0900)
committerTakashi Iwai <tiwai@suse.de>
Mon, 17 Jun 2019 06:18:35 +0000 (08:18 +0200)
The operation of duplex streams should be in critical section.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/bebob/bebob_pcm.c

index 530db7a7844c49144646320b21231a25915bd3fc..e21de44deaa91682015c814e72551c6b58fd5b48 100644 (file)
@@ -213,14 +213,15 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
 {
        struct snd_bebob *bebob = substream->private_data;
 
-       if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) {
-               mutex_lock(&bebob->mutex);
+       mutex_lock(&bebob->mutex);
+
+       if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
                bebob->substreams_counter--;
-               mutex_unlock(&bebob->mutex);
-       }
 
        snd_bebob_stream_stop_duplex(bebob);
 
+       mutex_unlock(&bebob->mutex);
+
        return snd_pcm_lib_free_vmalloc_buffer(substream);
 }