Message ID | 1476278544-3397-12-git-send-email-eric.auger@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 1bd16ff..1f120f9 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -125,7 +125,17 @@ static struct vfio_dma *vfio_find_dma_from_node(struct rb_node *top, if (type == VFIO_IOVA_ANY || dma->type == type) return dma; - return NULL; + /* restart 2 searches skipping the current node */ + if (start < dma->iova) { + dma = vfio_find_dma_from_node(node->rb_left, start, + size, type); + if (dma) + return dma; + } + if (start + size > dma->iova + dma->size) + dma = vfio_find_dma_from_node(node->rb_right, start, + size, type); + return dma; } /**