Skip to content

Commit

Permalink
amd_iommu: do not dereference a NULL pointer address.
Browse files Browse the repository at this point in the history
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]>
Signed-off-by: Joerg Roedel <[email protected]>
  • Loading branch information
maurizio-lombardi authored and joergroedel committed Sep 25, 2014
1 parent cafd254 commit 63eaa75
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/iommu/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 63eaa75

Please sign in to comment.