diff options
| author | Marek Szyprowski <m.szyprowski@samsung.com> | 2026-10-26 10:54:15 +0100 |
|---|---|---|
| committer | Marek Szyprowski <m.szyprowski@samsung.com> | 2026-11-05 08:56:32 +0100 |
| commit | ca010d38da7bf05a4572a54c2c16d6d64a758c3a (patch) | |
| tree | f3eb038d81519065d68e58eff9a4ee2f9a062aaf /kernel | |
| parent | 7ad92b81b415de806957b19828fc4777a9cf2216 (diff) | |
dma-pool: release CMA pages on atomic_pool_expand() error path
atomic_pool_expand() may allocate the pool backing pages from CMA via
dma_alloc_from_contiguous(), but the error path unconditionally frees
them with __free_pages(). This hands CMA pages to the buddy allocator
while leaving them marked as allocated in the CMA bitmap, permanently
leaking CMA capacity on every failed expansion.
Try dma_release_from_contiguous() first and fall back to __free_pages()
only for pages that did not come from CMA, as the code did before CMA
allocation was temporarily removed from the pool.
Fixes: d7e673ec2c8e ("dma-pool: Only allocate from CMA when in same memory zone")
Closes: https://sashiko.dev/#/bug/linux-fdfc6e83-15e4-4980-9818-691b034397e7
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20261026095423.966856-5-m.szyprowski@samsung.com
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/dma/pool.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c index 00f422a1e896..381b3cb28368 100644 --- a/kernel/dma/pool.c +++ b/kernel/dma/pool.c @@ -152,7 +152,8 @@ remove_mapping: dma_common_free_remap(addr, pool_size); free_page: #endif - if (!leak_pages) + if (!leak_pages && + !dma_release_from_contiguous(NULL, page, 1 << order)) __free_pages(page, order); out: return ret; |
