diff options
author | Takashi Iwai <tiwai@suse.de> | 2021-11-07 19:39:11 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-11-18 21:15:55 +0300 |
commit | 47047ae0b779bf8c2a3e18313110f2a89586e477 (patch) | |
tree | d1a34eb23a39072985ee6c4bb366d11303c72142 /sound/core | |
parent | b9d4a8993500dd2e95fa336c6b003a4f28880973 (diff) | |
download | linux-47047ae0b779bf8c2a3e18313110f2a89586e477.tar.xz |
ALSA: PCM: Fix NULL dereference at mmap checks
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: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20211107163911.13534-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/memalloc.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index c7c943c661e6..0b8a1c3eae1b 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -176,8 +176,11 @@ EXPORT_SYMBOL_GPL(snd_devm_alloc_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 |