under low memory conditions, alloc_pte() may return a NULL pointer.
iommu_map_page() does not check it and will panic the system.

Signed-off-by: Maurizio Lombardi <[email protected]>
---
 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 ecb0109..9585268 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1368,6 +1368,9 @@ static int iommu_map_page(struct protection_domain *dom,
        count     = PAGE_SIZE_PTE_COUNT(page_size);
        pte       = alloc_pte(dom, bus_addr, page_size, NULL, GFP_KERNEL);
 
+       if (!pte)
+               return -ENOMEM;
+
        for (i = 0; i < count; ++i)
                if (IOMMU_PTE_PRESENT(pte[i]))
                        return -EBUSY;
-- 
Maurizio Lombardi

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to