Skip to content

Commit

Permalink
ALSA: memalloc: Catch call with NULL snd_dma_buffer pointer
Browse files Browse the repository at this point in the history
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: 37af81c ("ALSA: core: Abstract memory alloc helpers")
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Nov 5, 2021
1 parent 7599acb commit dce9446
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sound/core/memalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit dce9446

Please sign in to comment.