summaryrefslogtreecommitdiff
path: root/drivers/vfio
diff options
context:
space:
mode:
authorAnthony Yznaga <anthony.yznaga@oracle.com>2021-08-23 09:35:50 -0700
committerAlex Williamson <alex.williamson@redhat.com>2021-08-24 12:09:50 -0600
commitffc95d1b8edb80d2dab77f2e8a823c8d93b06419 (patch)
tree295f50bada973e2c80d801401e6336d101e2f796 /drivers/vfio
parenteb24c1007e6852e024dc33b0dd9617b8500a1291 (diff)
vfio/type1: Fix vfio_find_dma_valid return
vfio_find_dma_valid is defined to return WAITED on success if it was necessary to wait. However, the loop forgets the WAITED value returned by vfio_wait() and returns 0 in a later iteration. Fix it. Signed-off-by: Anthony Yznaga <anthony.yznaga@oracle.com> Reviewed-by: Steve Sistare <steven.sistare@oracle.com> Link: https://lore.kernel.org/r/1629736550-2388-1-git-send-email-anthony.yznaga@oracle.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio')
-rw-r--r--drivers/vfio/vfio_iommu_type1.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 0b4f7c174c7a..0e9217687f5c 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -612,17 +612,17 @@ static int vfio_wait(struct vfio_iommu *iommu)
static int vfio_find_dma_valid(struct vfio_iommu *iommu, dma_addr_t start,
size_t size, struct vfio_dma **dma_p)
{
- int ret;
+ int ret = 0;
do {
*dma_p = vfio_find_dma(iommu, start, size);
if (!*dma_p)
- ret = -EINVAL;
+ return -EINVAL;
else if (!(*dma_p)->vaddr_invalid)
- ret = 0;
+ return ret;
else
ret = vfio_wait(iommu);
- } while (ret > 0);
+ } while (ret == WAITED);
return ret;
}