Skip to contentSkip to conversation

ALSA: memalloc: Catch call with NULL snd_dma_buffer pointer

PATCH New Takashi Iwai 1 participant 1 message Nov 5, 2021 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 sound/core/memalloc.c | 2 ++
 1 file changed, 2 insertions(+)
sound/core/memalloc.c +2 -0
index ea778f868cf3..ea9698cea2e3 100644
@@ -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;
Signature · 1 line
2.31.1