tu/drm/virtio: Do not free iova from heap for lazy BOs

When initializing a BO using a lazy VMA, the iova is provided by
the sparse VMA and was not allocated from the device's VMA heap.
Avoid calling util_vma_heap_free in the error path for such BOs
to prevent heap corruption and potential double-frees.

Fixes: 88d001383a ("tu: Add support for a "lazy" sparse VMA")
Signed-off-by: Valentine Burley <valentine.burley@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40507>
This commit is contained in:
Valentine Burley 2026-03-19 20:00:05 +01:00 committed by Marge Bot
parent f1366ca144
commit eb7897f57b

View file

@ -775,9 +775,11 @@ virtio_bo_init(struct tu_device *dev,
return VK_SUCCESS;
fail:
mtx_lock(&dev->vma_mutex);
util_vma_heap_free(&dev->vma, req.iova, size);
mtx_unlock(&dev->vma_mutex);
if (!lazy_vma) {
mtx_lock(&dev->vma_mutex);
util_vma_heap_free(&dev->vma, req.iova, size);
mtx_unlock(&dev->vma_mutex);
}
return result;
}