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: db88a490b8 ("tu: Avoid extraneous set_iova")
Signed-off-by: Valentine Burley <valentine.burley@collabora.com>
(cherry picked from commit 7a96bc3187)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40752>
This commit is contained in:
Valentine Burley 2026-03-19 11:12:24 +01:00 committed by Eric Engestrom
parent 28f24b21ee
commit 2aa33f41e6
2 changed files with 2 additions and 3 deletions

View file

@ -3864,7 +3864,7 @@
"description": "tu/drm/virtio: Move set_iova into success path of virtio_bo_init_dmabuf",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "db88a490b8d257b5409dc2161c28838a6bd53160",
"notes": null

View file

@ -853,10 +853,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;