Unlike the old allocator, alloc_iova_fast() will return 0 if it failed
to allocate a PFN. Since the callers of dma_ops_alloc_iova() would end
up treating that as a valid address, translate it to the DMA_ERROR_CODE
that they would expect.
Fixes: 256e4621c21a ("iommu/amd: Make use of the generic IOVA allocator")
Signed-off-by: Robin Murphy <[email protected]>
---
Just something I spotted whilst comparing dma_map_page() callchains...
drivers/iommu/amd_iommu.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 63cacf5d6cf2..489dc302899e 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1555,6 +1555,9 @@ static unsigned long dma_ops_alloc_iova(struct device
*dev,
if (!pfn)
pfn = alloc_iova_fast(&dma_dom->iovad, pages,
IOVA_PFN(dma_mask));
+ if (!pfn)
+ return DMA_ERROR_CODE;
+
return (pfn << PAGE_SHIFT);
}
--
2.12.2.dirty
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu