summaryrefslogtreecommitdiff
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2021-11-05 11:21:03 +0100
committerTakashi Iwai <tiwai@suse.de>2021-11-05 11:27:10 +0100
commitdce9446192439eaac81c21f517325fb473735e53 (patch)
tree23a1486d87c34cf4e496c18f3f1009ba45fc8563 /sound/core
parent7599acb7b9a1e33a410e33f13791647fba94e84f (diff)
ALSA: memalloc: Catch call with NULL snd_dma_buffer pointer
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: 37af81c5998f ("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>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/memalloc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c
index ea778f868cf3..ea9698cea2e3 100644
--- a/sound/core/memalloc.c
+++ b/sound/core/memalloc.c
@@ -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;