From 76da4569544f8b08de0d3044b7e4bc74a6a1df45 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 13 Dec 2021 10:21:47 +1000 Subject: [PATCH] crocus: cleanup bo exports for external objects This might have led to a leak in firefox/webrender/webgl scenarios Reviewed-by: Jason Ekstrand Fixes: f3630548f1da ("crocus: initial gallium driver for Intel gfx 4-7") Part-of: --- src/gallium/drivers/crocus/crocus_bufmgr.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gallium/drivers/crocus/crocus_bufmgr.c b/src/gallium/drivers/crocus/crocus_bufmgr.c index ff0ef11600f..aa70271ffee 100644 --- a/src/gallium/drivers/crocus/crocus_bufmgr.c +++ b/src/gallium/drivers/crocus/crocus_bufmgr.c @@ -609,6 +609,16 @@ bo_close(struct crocus_bo *bo) entry = _mesa_hash_table_search(bufmgr->handle_table, &bo->gem_handle); _mesa_hash_table_remove(bufmgr->handle_table, entry); + + list_for_each_entry_safe(struct bo_export, export, &bo->exports, link) { + struct drm_gem_close close = { .handle = export->gem_handle }; + intel_ioctl(export->drm_fd, DRM_IOCTL_GEM_CLOSE, &close); + + list_del(&export->link); + free(export); + } + } else { + assert(list_is_empty(&bo->exports)); } /* Close this object */