All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next 1/2] ALSA: pcm: oss: Restore params flag after failed reconfiguration
@ 2026-11-16  6:48 Ye Weihua
  2026-11-16  6:48 ` [PATCH -next 2/2] ALSA: pcm: oss: Clear params flag only after successful setup Ye Weihua
  2026-11-16 15:31 ` [PATCH -next 1/2] ALSA: pcm: oss: Restore params flag after failed reconfiguration Takashi Iwai
  0 siblings, 2 replies; 3+ messages in thread
From: Ye Weihua @ 2026-11-16  6:48 UTC (permalink / raw)
  To: Takashi Iwai, Jaroslav Kysela; +Cc: linux-sound, stable, Ye Weihua

snd_pcm_runtime_buffer_set_silence() may fail with -EBUSY when a
concurrent PCM transfer is accessing the buffer.  The error path
releases runtime->oss.buffer and clears the plugins, but leaves
runtime->oss.params cleared as well.  A subsequent small read/write
then skips the reconfiguration and dereferences the released buffer:

  Unable to handle kernel NULL pointer dereference at virtual address
  0000000000000000
  pc : __arch_copy_from_user+0x78/0x23c
  lr : snd_pcm_oss_write+0x10c/0x340 [snd_pcm_oss]

Restore runtime->oss.params on the error path so that the next OSS
operation reconfigures and reallocates the buffer.

Fixes: 47c27c9c9c72 ("ALSA: pcm: Improve the fix for race of buffer access at PCM OSS layer")
Cc: stable@vger.kernel.org
Signed-off-by: Ye Weihua <yeweihua4@huawei.com>
---
 sound/core/oss/pcm_oss.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 2d99df900f76..29812b0d1318 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -1082,12 +1082,14 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
 
 	runtime->oss.period_frames = snd_pcm_alsa_frames(substream, oss_period_size);
 
 	err = 0;
 failure:
-	if (err)
+	if (err) {
+		runtime->oss.params = 1;
 		snd_pcm_oss_release_buffers(substream);
+	}
 	kfree(sw_params);
 	kfree(params);
 	kfree(sparams);
 	return err;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-16 15:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16  6:48 [PATCH -next 1/2] ALSA: pcm: oss: Restore params flag after failed reconfiguration Ye Weihua
2026-11-16  6:48 ` [PATCH -next 2/2] ALSA: pcm: oss: Clear params flag only after successful setup Ye Weihua
2026-11-16 15:31 ` [PATCH -next 1/2] ALSA: pcm: oss: Restore params flag after failed reconfiguration Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.