Skip to content

Commit ffc95d1

Browse files
Anthony YznagaAlex Williamson
authored andcommitted
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>
1 parent eb24c10 commit ffc95d1

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/vfio/vfio_iommu_type1.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -612,17 +612,17 @@ static int vfio_wait(struct vfio_iommu *iommu)
612612
static int vfio_find_dma_valid(struct vfio_iommu *iommu, dma_addr_t start,
613613
size_t size, struct vfio_dma **dma_p)
614614
{
615-
int ret;
615+
int ret = 0;
616616

617617
do {
618618
*dma_p = vfio_find_dma(iommu, start, size);
619619
if (!*dma_p)
620-
ret = -EINVAL;
620+
return -EINVAL;
621621
else if (!(*dma_p)->vaddr_invalid)
622-
ret = 0;
622+
return ret;
623623
else
624624
ret = vfio_wait(iommu);
625-
} while (ret > 0);
625+
} while (ret == WAITED);
626626

627627
return ret;
628628
}

0 commit comments

Comments
 (0)