Skip to content

Commit 604a0fe

Browse files
committed
ALSA: pcm: Drop superfluous NULL check in snd_pcm_format_set_silence()
We applied a fix for a KASAN issue for snd_pcm_format_set_silence(), and it introduced a NULL check of pat. But this turned out to be utterly superfluous; it points to pcm_formats[].silence, and this is an array, which can be never NULL. The problem (supposedly) it tried to address at that time was likely already fixed by another commit 8423f0b ("ALSA: pcm: oss: Fix race at SNDCTL_DSP_SYNC") instead. So let's drop the superfluous NULL check again. While we're at it, keep the whitespace fix and move the pat assignment after the width check for a bit better code readability. Fixes: 2f7a26a ("ALSA: pcm: Test for "silence" field in struct "pcm_format_data"") Link: https://patch.msgid.link/20250227095150.8187-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 0f1f26c commit 604a0fe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sound/core/pcm_misc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,9 @@ int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int
432432
if (samples == 0)
433433
return 0;
434434
width = pcm_formats[(INT)format].phys; /* physical width */
435-
pat = pcm_formats[(INT)format].silence;
436-
if (!width || !pat)
435+
if (!width)
437436
return -EINVAL;
437+
pat = pcm_formats[(INT)format].silence;
438438
/* signed or 1 byte data */
439439
if (pcm_formats[(INT)format].signd == 1 || width <= 8) {
440440
unsigned int bytes = samples * width / 8;

0 commit comments

Comments
 (0)