ALSA: pcm: Warn if doubly preallocated

Warn if snd_pcm_lib_preallocate_pages*() is applied to the stream that
has already the preallocated buffers and skip the allocation.  It's a
clearly a driver bug.

Link: https://lore.kernel.org/r/20191105191007.18150-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2019-11-05 20:10:06 +01:00
parent abffd8d0d5
commit a55eaf177a
1 changed files with 2 additions and 0 deletions

View File

@ -221,6 +221,8 @@ void snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream,
int type, struct device *data, int type, struct device *data,
size_t size, size_t max) size_t size, size_t max)
{ {
if (snd_BUG_ON(substream->dma_buffer.dev.type))
return;
substream->dma_buffer.dev.type = type; substream->dma_buffer.dev.type = type;
substream->dma_buffer.dev.dev = data; substream->dma_buffer.dev.dev = data;
snd_pcm_lib_preallocate_pages1(substream, size, max); snd_pcm_lib_preallocate_pages1(substream, size, max);