From 7a96bc3187382eea0cd89cb46720b0908a7c3831 Mon Sep 17 00:00:00 2001 From: Valentine Burley Date: Thu, 19 Mar 2026 11:12:24 +0100 Subject: [PATCH] tu/drm/virtio: Move set_iova into success path of virtio_bo_init_dmabuf set_iova() was called unconditionally after tu_bo_init(), even on the failure path where the BO has been zeroed. This would call set_iova() with res_id 0 and a stale iova, corrupting the iova mapping. Move set_iova() into the success branch so it is only called when tu_bo_init() succeeds. Fixes: db88a490b8d2 ("tu: Avoid extraneous set_iova") Signed-off-by: Valentine Burley Part-of: --- src/freedreno/vulkan/tu_knl_drm_virtio.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/freedreno/vulkan/tu_knl_drm_virtio.cc b/src/freedreno/vulkan/tu_knl_drm_virtio.cc index f2570c731fd..af0bae25c63 100644 --- a/src/freedreno/vulkan/tu_knl_drm_virtio.cc +++ b/src/freedreno/vulkan/tu_knl_drm_virtio.cc @@ -855,10 +855,9 @@ virtio_bo_init_dmabuf(struct tu_device *dev, memset(bo, 0, sizeof(*bo)); } else { *out_bo = bo; + set_iova(dev, bo->res_id, iova); } - set_iova(dev, bo->res_id, iova); - out_unlock: u_rwlock_wrunlock(&dev->dma_bo_lock); return result;