Skip to content

Commit

Permalink
vfio/type1: Fix vfio_find_dma_valid return
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Anthony Yznaga authored and Alex Williamson committed Aug 24, 2021
1 parent eb24c10 commit ffc95d1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/vfio/vfio_iommu_type1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ffc95d1

Please sign in to comment.