]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ALSA: memalloc: Catch call with NULL snd_dma_buffer pointer
authorTakashi Iwai <tiwai@suse.de>
Fri, 5 Nov 2021 10:21:03 +0000 (11:21 +0100)
committerTakashi Iwai <tiwai@suse.de>
Fri, 5 Nov 2021 10:27:10 +0000 (11:27 +0100)
Although we've covered all calls with NULL dma buffer pointer, so far,
there may be still some else in the wild.  For catching such a case
more easily, add a WARN_ON_ONCE() in snd_dma_get_ops().

Fixes: 1dd57c925abb ("ALSA: core: Abstract memory alloc helpers")
Link: https://lore.kernel.org/r/20211105102103.28148-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/memalloc.c

index ea778f868cf338643c3edc13d7d330e9a4fb6f38..ea9698cea2e3b3e475287e57e1fe38c9737bd880 100644 (file)
@@ -631,6 +631,8 @@ static const struct snd_malloc_ops *dma_ops[] = {
 
 static const struct snd_malloc_ops *snd_dma_get_ops(struct snd_dma_buffer *dmab)
 {
+       if (WARN_ON_ONCE(!dmab))
+               return NULL;
        if (WARN_ON_ONCE(dmab->dev.type <= SNDRV_DMA_TYPE_UNKNOWN ||
                         dmab->dev.type >= ARRAY_SIZE(dma_ops)))
                return NULL;