diff options
author | Jerry Snitselaar <jsnitsel@redhat.com> | 2019-01-19 10:38:05 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-03-13 14:02:27 -0700 |
commit | 9e1f977d82eca514e71826bdb9cb34da2e687f0d (patch) | |
tree | a4b9b867f7898392126ec17ba19444b623b0c1cb /drivers/iommu | |
parent | 697863bf7d724ad067988468b19f8b411993151b (diff) | |
download | linux-stable-9e1f977d82eca514e71826bdb9cb34da2e687f0d.tar.gz linux-stable-9e1f977d82eca514e71826bdb9cb34da2e687f0d.tar.bz2 linux-stable-9e1f977d82eca514e71826bdb9cb34da2e687f0d.zip |
iommu/amd: Unmap all mapped pages in error path of map_sg
[ Upstream commit f1724c0883bb0ce93b8dcb94b53dcca3b75ac9a7 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/amd_iommu.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 2a5c05ca7fca..2ab87e3f07e6 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2555,7 +2555,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; } } |