Thread (859 messages) flat view 859 messages, 8 authors, 2021-11-16
STALE1760d

[PATCH 5.14 045/849] ALSA: PCM: Fix NULL dereference at mmap checks

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: 2021-11-16 01:52:07
Also in: lkml

From: Takashi Iwai <redacted>

commit 8e537d5dec34cac746dd6abf6a83e5de3aa471fc upstream.

The recent refactoring of mmap handling caused Oops on some devices
that don't use the standard memory allocations.  This patch addresses
it by allowing snd_dma_buffer_mmap() helper to receive the NULL
pointer dmab argument (and return an error appropriately).

Fixes: a202bd1ad86d ("ALSA: core: Move mmap handler into memalloc ops")
Cc: <redacted>
Link: https://lore.kernel.org/r/20211107163911.13534-1-tiwai@suse.de (local)
Signed-off-by: Takashi Iwai <redacted>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 sound/core/memalloc.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
--- a/sound/core/memalloc.c
+++ b/sound/core/memalloc.c
@@ -135,8 +135,11 @@ EXPORT_SYMBOL(snd_dma_free_pages);
 int snd_dma_buffer_mmap(struct snd_dma_buffer *dmab,
 			struct vm_area_struct *area)
 {
-	const struct snd_malloc_ops *ops = snd_dma_get_ops(dmab);
+	const struct snd_malloc_ops *ops;
 
+	if (!dmab)
+		return -ENOENT;
+	ops = snd_dma_get_ops(dmab);
 	if (ops && ops->mmap)
 		return ops->mmap(dmab, area);
 	else

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help