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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Mar 2019 21:04:55 +0000 (14:04 -0700)
commit50c382e88a79adc366ef12276a10461b3ebe8af9
tree59416d9dd8ac9e57206b08764c80d57a4592376d
parent8a6c9f65e75526e72bc114638b97a624a7c7d9f8
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>
drivers/iommu/amd_iommu.c