Skip to content

Commit 011b559

Browse files
ColinIanKingtiwai
authored andcommitted
ALSA: pcm: Check for null pointer of pointer substream before dereferencing it
Pointer substream is being dereferenced on the assignment of pointer card before substream is being null checked with the macro PCM_RUNTIME_CHECK. Although PCM_RUNTIME_CHECK calls BUG_ON, it still is useful to perform the the pointer check before card is assigned. Fixes: d4cfb30 ("ALSA: pcm: Set per-card upper limit of PCM buffer allocations") Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Link: https://lore.kernel.org/r/20220424205945.1372247-1-colin.i.king@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent c92b576 commit 011b559

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

sound/core/pcm_memory.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,6 @@ EXPORT_SYMBOL(snd_pcm_lib_malloc_pages);
453453
*/
454454
int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream)
455455
{
456-
struct snd_card *card = substream->pcm->card;
457456
struct snd_pcm_runtime *runtime;
458457

459458
if (PCM_RUNTIME_CHECK(substream))
@@ -462,6 +461,8 @@ int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream)
462461
if (runtime->dma_area == NULL)
463462
return 0;
464463
if (runtime->dma_buffer_p != &substream->dma_buffer) {
464+
struct snd_card *card = substream->pcm->card;
465+
465466
/* it's a newly allocated buffer. release it now. */
466467
do_free_pages(card, runtime->dma_buffer_p);
467468
kfree(runtime->dma_buffer_p);

0 commit comments

Comments
 (0)