Re: [PATCH] ALSA: pcm: Fix unlocked state reads in read/write file ops

From: Takashi Iwai

Date: Wed Jun 10 2026 - 11:05:42 EST


On Wed, 10 Jun 2026 13:31:30 +0200,
Cássio Gabriel wrote:
>
> The PCM read/write and readv/writev file operations reject streams in
> OPEN or DISCONNECTED state before accessing the configured runtime
> parameters. However, each operation reads runtime->state without the
> PCM stream lock.
>
> PCM state updates are serialized by the stream lock and may occur
> concurrently from IRQ context. Use a local predicate based on
> snd_pcm_get_state() to take a locked state snapshot for these VFS entry
> checks.
>
> This also consolidates the duplicated OPEN and DISCONNECTED tests. The
> conditions and returned errors remain unchanged.
>
> Signed-off-by: Cássio Gabriel <cassiogabrielcontato@xxxxxxxxx>

Applied to for-next branch now. Thanks.


Takashi