mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 15:48:36 +02:00
tu/drm/virtio: Fix GEM handle leak on failed dmabuf res_id lookup
When vdrm_handle_to_res_id fails in virtio_bo_init_dmabuf, the handle obtained from vdrm_dmabuf_to_handle was leaked. Closing the handle is safe despite the lack of vdrm refcounting because dma_bo_lock is held and already-imported BOs return early. At this point, we are the sole holder of the handle. While here, use the local vdrm variable consistently. Fixes:6ca192f586("turnip: virtio: fix iova leak upon found already imported dmabuf") Signed-off-by: Valentine Burley <valentine.burley@collabora.com> (cherry picked from commitf2c89f0188) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40752>
This commit is contained in:
parent
e984faec26
commit
bb0c3b12b9
2 changed files with 3 additions and 3 deletions
|
|
@ -3824,7 +3824,7 @@
|
|||
"description": "tu/drm/virtio: Fix GEM handle leak on failed dmabuf res_id lookup",
|
||||
"nominated": true,
|
||||
"nomination_type": 2,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "6ca192f586fe1470a97b6f34bce7761a760ce15d",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -822,7 +822,7 @@ virtio_bo_init_dmabuf(struct tu_device *dev,
|
|||
|
||||
res_id = vdrm_handle_to_res_id(vdrm, handle);
|
||||
if (!res_id) {
|
||||
/* XXX gem_handle potentially leaked here since no refcnt */
|
||||
vdrm_bo_close(vdrm, handle);
|
||||
result = vk_error(dev, VK_ERROR_INVALID_EXTERNAL_HANDLE);
|
||||
goto out_unlock;
|
||||
}
|
||||
|
|
@ -844,7 +844,7 @@ virtio_bo_init_dmabuf(struct tu_device *dev,
|
|||
TU_BO_ALLOC_DMABUF, &iova);
|
||||
mtx_unlock(&dev->vma_mutex);
|
||||
if (result != VK_SUCCESS) {
|
||||
vdrm_bo_close(dev->vdev->vdrm, handle);
|
||||
vdrm_bo_close(vdrm, handle);
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue