Skip to content

Commit c4824ae

Browse files
committed
ALSA: pcm: Fix mmap capability check
The hw_support_mmap() doesn't cover all memory allocation types and might use a wrong device pointer for checking the capability. Check the all memory allocation types more completely. Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20210720092640.12338-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 114613f commit c4824ae

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎sound/core/pcm_native.c‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,18 @@ static bool hw_support_mmap(struct snd_pcm_substream *substream)
246246
if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_MMAP))
247247
return false;
248248

249-
if (substream->ops->mmap ||
250-
(substream->dma_buffer.dev.type != SNDRV_DMA_TYPE_DEV &&
251-
substream->dma_buffer.dev.type != SNDRV_DMA_TYPE_DEV_UC))
249+
if (substream->ops->mmap)
252250
return true;
253251

254-
return dma_can_mmap(substream->dma_buffer.dev.dev);
252+
switch (substream->dma_buffer.dev.type) {
253+
case SNDRV_DMA_TYPE_UNKNOWN:
254+
return false;
255+
case SNDRV_DMA_TYPE_CONTINUOUS:
256+
case SNDRV_DMA_TYPE_VMALLOC:
257+
return true;
258+
default:
259+
return dma_can_mmap(substream->dma_buffer.dev.dev);
260+
}
255261
}
256262

257263
static int constrain_mask_params(struct snd_pcm_substream *substream,

0 commit comments

Comments
 (0)