mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									114613f62f
								
							
						
					
					
						commit
						c4824ae7db
					
				
					 1 changed files with 10 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -246,12 +246,18 @@ static bool hw_support_mmap(struct snd_pcm_substream *substream)
 | 
			
		|||
	if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_MMAP))
 | 
			
		||||
		return false;
 | 
			
		||||
 | 
			
		||||
	if (substream->ops->mmap ||
 | 
			
		||||
	    (substream->dma_buffer.dev.type != SNDRV_DMA_TYPE_DEV &&
 | 
			
		||||
	     substream->dma_buffer.dev.type != SNDRV_DMA_TYPE_DEV_UC))
 | 
			
		||||
	if (substream->ops->mmap)
 | 
			
		||||
		return true;
 | 
			
		||||
 | 
			
		||||
	return dma_can_mmap(substream->dma_buffer.dev.dev);
 | 
			
		||||
	switch (substream->dma_buffer.dev.type) {
 | 
			
		||||
	case SNDRV_DMA_TYPE_UNKNOWN:
 | 
			
		||||
		return false;
 | 
			
		||||
	case SNDRV_DMA_TYPE_CONTINUOUS:
 | 
			
		||||
	case SNDRV_DMA_TYPE_VMALLOC:
 | 
			
		||||
		return true;
 | 
			
		||||
	default:
 | 
			
		||||
		return dma_can_mmap(substream->dma_buffer.dev.dev);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int constrain_mask_params(struct snd_pcm_substream *substream,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue