summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/winsys/virgl/drm/virgl_drm_winsys.c')
-rw-r--r--src/gallium/winsys/virgl/drm/virgl_drm_winsys.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
index f0e95eff8a6..0031db7d278 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
@@ -72,6 +72,16 @@ static void virgl_hw_res_destroy(struct virgl_drm_winsys *qdws,
struct drm_gem_close args;
mtx_lock(&qdws->bo_handles_mutex);
+
+ /* We intentionally avoid taking the lock in
+ * virgl_drm_resource_reference. Now that the
+ * lock is taken, we need to check the refcount
+ * again. */
+ if (pipe_is_referenced(&res->reference)) {
+ mtx_unlock(&qdws->bo_handles_mutex);
+ return;
+ }
+
_mesa_hash_table_remove_key(qdws->bo_handles,
(void *)(uintptr_t)res->bo_handle);
if (res->flink_name)