Skip to content

Commit d2913a0

Browse files
committed
ALSA: pcm: Add sanity NULL check for the default mmap fault handler
A driver might allow the mmap access before initializing its runtime->dma_area properly. Add a proper NULL check before passing to virt_to_page() for avoiding a panic. Reported-by: [email protected] Cc: <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 5638629 commit d2913a0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sound/core/pcm_native.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3813,9 +3813,11 @@ static vm_fault_t snd_pcm_mmap_data_fault(struct vm_fault *vmf)
38133813
return VM_FAULT_SIGBUS;
38143814
if (substream->ops->page)
38153815
page = substream->ops->page(substream, offset);
3816-
else if (!snd_pcm_get_dma_buf(substream))
3816+
else if (!snd_pcm_get_dma_buf(substream)) {
3817+
if (WARN_ON_ONCE(!runtime->dma_area))
3818+
return VM_FAULT_SIGBUS;
38173819
page = virt_to_page(runtime->dma_area + offset);
3818-
else
3820+
} else
38193821
page = snd_sgbuf_get_page(snd_pcm_get_dma_buf(substream), offset);
38203822
if (!page)
38213823
return VM_FAULT_SIGBUS;

0 commit comments

Comments
 (0)