mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-11 20:45:57 -04:00
iommu/dma: Check atomic pool allocation result directly
The non-blocking, non-coherent allocation path uses dma_alloc_from_pool(),
which returns the allocated page and fills cpu_addr only on success.
Do not rely on cpu_addr to detect allocation failure in this path. Check
the returned page directly before using it for the IOMMU mapping.
Fixes: 9420139f51 ("dma-pool: fix coherent pool allocations for IOMMU mappings")
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Tested-by: Michael Kelley <mhklinux@outlook.com>
Tested-by: Mostafa Saleh <smostafa@google.com>
Reviewed-by: Petr Tesarik <ptesarik@suse.com>
Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
Link: https://lore.kernel.org/r/20260717180442.110954-4-aneesh.kumar@kernel.org
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
This commit is contained in:
committed by
Marek Szyprowski
parent
0510cb5b23
commit
af95a0ebc0
@@ -1671,13 +1671,16 @@ void *iommu_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) &&
|
||||
!gfpflags_allow_blocking(gfp) && !coherent)
|
||||
!gfpflags_allow_blocking(gfp) && !coherent) {
|
||||
page = dma_alloc_from_pool(dev, PAGE_ALIGN(size), &cpu_addr,
|
||||
gfp, NULL);
|
||||
else
|
||||
gfp, NULL);
|
||||
if (!page)
|
||||
return NULL;
|
||||
} else {
|
||||
cpu_addr = iommu_dma_alloc_pages(dev, size, &page, gfp, attrs);
|
||||
if (!cpu_addr)
|
||||
return NULL;
|
||||
if (!cpu_addr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*handle = __iommu_dma_map(dev, page_to_phys(page), size, ioprot,
|
||||
dev->coherent_dma_mask);
|
||||
|
||||
Reference in New Issue
Block a user