]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
iommu/amd: Unmap all mapped pages in error path of map_sg
authorJerry Snitselaar <jsnitsel@redhat.com>
Sat, 19 Jan 2019 17:38:05 +0000 (10:38 -0700)
committerJoerg Roedel <jroedel@suse.de>
Tue, 22 Jan 2019 11:03:26 +0000 (12:03 +0100)
In the error path of map_sg there is an incorrect if condition
for breaking out of the loop that searches the scatterlist
for mapped pages to unmap. Instead of breaking out of the
loop once all the pages that were mapped have been unmapped,
it will break out of the loop after it has unmapped 1 page.
Fix the condition, so it breaks out of the loop only after
all the mapped pages have been unmapped.

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

index 418df8ff3e5084a91b3b60cb14c2db3d466f50d2..843b825cc1c4b34c8fc1fdf92a862d0841de56cf 100644 (file)
@@ -2617,7 +2617,7 @@ out_unmap:
                        bus_addr  = address + s->dma_address + (j << PAGE_SHIFT);
                        iommu_unmap_page(domain, bus_addr, PAGE_SIZE);
 
-                       if (--mapped_pages)
+                       if (--mapped_pages == 0)
                                goto out_free_iova;
                }
        }