From: Maurizio Lombardi Date: Thu, 11 Sep 2014 10:28:03 +0000 (+0200) Subject: amd_iommu: do not dereference a NULL pointer address. X-Git-Tag: v3.18-rc1~38^2^6~1 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=63eaa75e4362ac7981a7e619196a9c75fd03d717;p=karo-tx-linux.git amd_iommu: do not dereference a NULL pointer address. 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 Signed-off-by: Joerg Roedel --- diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 989c1ae03979..23c5be6a3a1e 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -1393,6 +1393,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;