[PATCH 5/6] ALSA: pcm: use locked state read in snd_pcm_drop()
Omer Cohen <[email protected]> Fri, 26 Jun 2026 16:47:08 +0300
| Newsgroups | org.alsa-project.alsa-devel,org.kernel.vger.stable |
|---|---|
| Message-ID | <[email protected]> |
snd_pcm_drop() reads runtime->state without the stream lock at lines
2274-2275 to check for OPEN and DISCONNECTED states. The stream lock
is acquired shortly after at line 2278.
Commit 7bc02ab446d3 ("ALSA: pcm: Fix unlocked state reads in
read/write file ops") fixed this exact pattern in the read and write
paths but missed snd_pcm_drop().
Use snd_pcm_get_state() which acquires the stream lock for the read.
Fixes: f0061c18c169 ("ALSA: pcm: Avoid reference to status->state")
Cc: [email protected]
Reported-by: Omer Cohen <[email protected]>
Signed-off-by: Omer Cohen <[email protected]>
---
sound/core/pcm_native.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index XXXXXXXXXXXX..XXXXXXXXXXXX 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -2265,13 +2265,14 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream)
static int snd_pcm_drop(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime;
+ snd_pcm_state_t state;
int result = 0;
if (PCM_RUNTIME_CHECK(substream))
return -ENXIO;
runtime = substream->runtime;
- if (runtime->state == SNDRV_PCM_STATE_OPEN ||
- runtime->state == SNDRV_PCM_STATE_DISCONNECTED)
+ state = snd_pcm_get_state(substream);
+ if (state == SNDRV_PCM_STATE_OPEN ||
+ state == SNDRV_PCM_STATE_DISCONNECTED)
return -EBADFD;
guard(pcm_stream_lock_irq)(substream);
--
2.43.0