iommu/amd: Call free_iova_fast with pfn in map_sg
authorJerry Snitselaar <jsnitsel@redhat.com>
Thu, 17 Jan 2019 19:29:02 +0000 (12:29 -0700)
committerJoerg Roedel <jroedel@suse.de>
Tue, 22 Jan 2019 10:55:31 +0000 (11:55 +0100)
In the error path of map_sg, free_iova_fast is being called with
address instead of the pfn. This results in a bad value getting into
the rcache, and can result in hitting a BUG_ON when
iova_magazine_free_pfns is called.

Cc: Joerg Roedel <joro@8bytes.org>
Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
Fixes: 80187fd39dcb ("iommu/amd: Optimize map_sg and unmap_sg")
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd_iommu.c

index 87ba23a75b381ff245690a1106ddf190b0b327f7..418df8ff3e5084a91b3b60cb14c2db3d466f50d2 100644 (file)
@@ -2623,7 +2623,7 @@ out_unmap:
        }
 
 out_free_iova:
-       free_iova_fast(&dma_dom->iovad, address, npages);
+       free_iova_fast(&dma_dom->iovad, address >> PAGE_SHIFT, npages);
 
 out_err:
        return 0;