Skip to content

Commit 47c27c9

Browse files
perexgtiwai
authored andcommitted
ALSA: pcm: Improve the fix for race of buffer access at PCM OSS layer
Handle the error code from snd_pcm_buffer_access_lock() in snd_pcm_runtime_buffer_set_silence() function. Found by Alexandros Panagiotou <apanagio@redhat.com> Fixes: 93a81ca ("ALSA: pcm: Fix race of buffer access at PCM OSS layer") Cc: stable@vger.kernel.org # 6.15 Signed-off-by: Jaroslav Kysela <perex@perex.cz> Link: https://patch.msgid.link/20260107213642.332954-1-perex@perex.cz Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 9ed7a28 commit 47c27c9

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

include/sound/pcm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, struct vm_area_s
14021402
#define snd_pcm_lib_mmap_iomem NULL
14031403
#endif
14041404

1405-
void snd_pcm_runtime_buffer_set_silence(struct snd_pcm_runtime *runtime);
1405+
int snd_pcm_runtime_buffer_set_silence(struct snd_pcm_runtime *runtime);
14061406

14071407
/**
14081408
* snd_pcm_limit_isa_dma_size - Get the max size fitting with ISA DMA transfer

sound/core/oss/pcm_oss.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,9 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
10741074
runtime->oss.params = 0;
10751075
runtime->oss.prepare = 1;
10761076
runtime->oss.buffer_used = 0;
1077-
snd_pcm_runtime_buffer_set_silence(runtime);
1077+
err = snd_pcm_runtime_buffer_set_silence(runtime);
1078+
if (err < 0)
1079+
goto failure;
10781080

10791081
runtime->oss.period_frames = snd_pcm_alsa_frames(substream, oss_period_size);
10801082

sound/core/pcm_native.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,13 +730,18 @@ static void snd_pcm_buffer_access_unlock(struct snd_pcm_runtime *runtime)
730730
}
731731

732732
/* fill the PCM buffer with the current silence format; called from pcm_oss.c */
733-
void snd_pcm_runtime_buffer_set_silence(struct snd_pcm_runtime *runtime)
733+
int snd_pcm_runtime_buffer_set_silence(struct snd_pcm_runtime *runtime)
734734
{
735-
snd_pcm_buffer_access_lock(runtime);
735+
int err;
736+
737+
err = snd_pcm_buffer_access_lock(runtime);
738+
if (err < 0)
739+
return err;
736740
if (runtime->dma_area)
737741
snd_pcm_format_set_silence(runtime->format, runtime->dma_area,
738742
bytes_to_samples(runtime, runtime->dma_bytes));
739743
snd_pcm_buffer_access_unlock(runtime);
744+
return 0;
740745
}
741746
EXPORT_SYMBOL_GPL(snd_pcm_runtime_buffer_set_silence);
742747

0 commit comments

Comments
 (0)