diff options
| author | Sasha Levin <sashal@kernel.org> | 2026-10-28 10:44:41 -0400 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2026-10-31 16:33:36 +0100 |
| commit | 016fe9695e6dc1322ddfe8c7dbc7b973483b4a24 (patch) | |
| tree | 2657e66c0c0187920cb3be70e636360c49d46fd0 /scripts/stackusage | |
| parent | 74f6055d0c5997b13e6a5253fdc2263f3af90408 (diff) | |
ALSA: memalloc: Free the new pages when WC DMA mapping fails
snd_dma_wc_alloc() keeps the newly allocated pages in a local variable,
and snd_dma_alloc_dir_pages() stores them in dmab->area only after
->alloc() returns. If dma_map_single() fails, the error path passes
dmab->area to do_free_pages() instead, and that is still NULL at this
point for the usual callers.
The pages are then leaked with their write-combining attribute still
set, set_memory_wb() warns about the zero address, and for buffers
larger than a page free_pages_exact() goes on to free the struct pages
of the bogus addresses 4096, 8192 and so on. With CONFIG_DEBUG_VM that
hits the VM_BUG_ON() in free_pages():
kernel BUG at mm/page_alloc.c:5600!
RIP: 0010:free_pages_exact+0xcb/0xd0
Call Trace:
snd_dma_wc_alloc+0x14f/0x160 [snd_pcm]
snd_dma_alloc_dir_pages+0x4f/0x80 [snd_pcm]
This was reproduced on an x86 guest without swiotlb by allocating
SNDRV_DMA_TYPE_DEV_WC buffers for a device with a 24-bit streaming DMA
mask, so that dma_map_single() fails.
Free the pages that were just allocated.
Fixes: c880a5146642 ("ALSA: memalloc: Use proper DMA mapping API for x86 WC buffer allocations")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Link: https://patch.msgid.link/20261028144441.992127-1-sashal@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'scripts/stackusage')
0 files changed, 0 insertions, 0 deletions
