]> git.baikalelectronics.ru Git - kernel.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)
commit67131e9b8c2e79e161116c02768658496396ad90
tree0b3d9b1b3c463f7d0e89f041c1783d7ea13d3a1c
parent87abb37b73608fe4855499580316d54f56b364e8
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