diff mbox series

ALSA: pcm: Fix mmap without buffer preallocation

Message ID 20210720092732.12412-1-tiwai@suse.de (mailing list archive)
State Accepted
Commit d371588910715ebf7fa8e3a5d21ea5169c852927
Headers show
Series ALSA: pcm: Fix mmap without buffer preallocation | expand

Commit Message

Takashi Iwai July 20, 2021, 9:27 a.m. UTC
The recent rewrite of the memory allocation helpers also changed the
page extraction to a common helper, snd_sgbuf_get_page().  But this
assumes implicitly that the buffer was allocated via the standard
helper (usually via preallocation), and didn't consider the case of
the manual buffer handling.

This patch fixes it and also covers the manual buffer management.

Fixes: 37af81c5998f ("ALSA: core: Abstract memory alloc helpers")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/core/pcm_native.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 6919d2943b9d..6a2971a7e6a1 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3675,6 +3675,8 @@  static vm_fault_t snd_pcm_mmap_data_fault(struct vm_fault *vmf)
 		return VM_FAULT_SIGBUS;
 	if (substream->ops->page)
 		page = substream->ops->page(substream, offset);
+	else if (!snd_pcm_get_dma_buf(substream))
+		page = virt_to_page(runtime->dma_area + offset);
 	else
 		page = snd_sgbuf_get_page(snd_pcm_get_dma_buf(substream), offset);
 	if (!page)