]> git.karo-electronics.de Git - karo-tx-linux.git/commit
VFIO: vfio_iommu_type1: fix bug caused by break in nested loop
authorAntonios Motakis <a.motakis@virtualopensystems.com>
Fri, 11 Oct 2013 16:40:46 +0000 (10:40 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Fri, 11 Oct 2013 16:40:46 +0000 (10:40 -0600)
commitd93b3ac0edb85b1c1e8fe0a065c1e5045783e2f6
tree0b3d9b1b3c463f7d0e89f041c1783d7ea13d3a1c
parentd0e639c9e06d44e713170031fe05fb60ebe680af
VFIO: vfio_iommu_type1: fix bug caused by break in nested loop

In vfio_iommu_type1.c there is a bug in vfio_dma_do_map, when checking
that pages are not already mapped. Since the check is being done in a
for loop nested within the main loop, breaking out of it does not create
the intended behavior. If the underlying IOMMU driver returns a non-NULL
value, this will be ignored and mapping the DMA range will be attempted
anyway, leading to unpredictable behavior.

This interracts badly with the ARM SMMU driver issue fixed in the patch
that was submitted with the title:
"[PATCH 2/2] ARM: SMMU: return NULL on error in arm_smmu_iova_to_phys"
Both fixes are required in order to use the vfio_iommu_type1 driver
with an ARM SMMU.

This patch refactors the function slightly, in order to also make this
kind of bug less likely.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio_iommu_type1.c