Skip to contentSkip to conversation

ALSA: pcm: Call snd_pcm_sync_stop outside spinlock in snd_pcm_drop()

PATCH New Takashi Iwai 1 participant 1 message Oct 15 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: pcm: Call snd_pcm_sync_stop outside spinlock in snd_pcm_drop()

In the recent addition of snd_pcm_sync_stop() call at snd_pcm_drop(), I overlooked the guard() line in snd_pcm_drop() (and the review overlooked, too) -- it must be called outside, of course!

Let's fix it. Now guard() became scoped_guard(), and its range is shown more clearly.

Fixes fdf9a21cda78 ("ALSA: pcm: Apply sync-stop at SNDRV_PCM_IOCTL_DROP ioctl")
---
 sound/core/pcm_native.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
sound/core/pcm_native.c +10 -9
index 05097f2630ad..f2e378696c7e 100644
@@ -2307,17 +2307,18 @@ static int snd_pcm_drop(struct snd_pcm_substream *substream)
 		return -ENXIO;
 	runtime = substream->runtime;
 
-	guard(pcm_stream_lock_irq)(substream);
-	if (runtime->state == SNDRV_PCM_STATE_OPEN ||
-	    runtime->state == SNDRV_PCM_STATE_DISCONNECTED)
-		return -EBADFD;
+	scoped_guard(pcm_stream_lock_irq, substream) {
+		if (runtime->state == SNDRV_PCM_STATE_OPEN ||
+		    runtime->state == SNDRV_PCM_STATE_DISCONNECTED)
+			return -EBADFD;
 
-	/* resume pause */
-	if (runtime->state == SNDRV_PCM_STATE_PAUSED)
-		snd_pcm_pause(substream, false);
+		/* resume pause */
+		if (runtime->state == SNDRV_PCM_STATE_PAUSED)
+			snd_pcm_pause(substream, false);
 
-	result = snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
-	/* runtime->control->appl_ptr = runtime->status->hw_ptr; */
+		result = snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
+		/* runtime->control->appl_ptr = runtime->status->hw_ptr; */
+	}
 
 	snd_pcm_sync_stop(substream, true);
 
Signature · 1 line
2.55.0