tu/drm/virtio: Fix GEM handle leak in tu_bo_init error path

In tu_bo_init, if growing the submit BO list fails, the GEM handle
must be closed. However, bo->gem_handle is only populated later
via compound assignment. Use the gem_handle parameter directly
to ensure the correct handle is closed and not leaked.

Fixes: d67d501af4 ("tu/drm/virtio: Switch to vdrm helper")
Signed-off-by: Valentine Burley <valentine.burley@collabora.com>
(cherry picked from commit 316d9b0209)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40752>
This commit is contained in:
Valentine Burley 2026-03-19 20:01:13 +01:00 committed by Eric Engestrom
parent 9ca275f29a
commit e984faec26
2 changed files with 2 additions and 2 deletions

View file

@ -3834,7 +3834,7 @@
"description": "tu/drm/virtio: Fix GEM handle leak in tu_bo_init error path",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "d67d501af46f04bf12a16110f3a1e86b565cac96",
"notes": null

View file

@ -593,7 +593,7 @@ tu_bo_init(struct tu_device *dev,
if (!new_ptr) {
dev->submit_bo_count--;
mtx_unlock(&dev->bo_mutex);
vdrm_bo_close(dev->vdev->vdrm, bo->gem_handle);
vdrm_bo_close(dev->vdev->vdrm, gem_handle);
return VK_ERROR_OUT_OF_HOST_MEMORY;
}