From 1933436ada09e3c40870b1408f1a64e17f96346f Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 31 Jan 2024 12:39:08 -0500 Subject: [PATCH] zink: prune dmabuf export tracking when adding resource binds this avoids invalid access for the stack resource in add_resource_bind() when adding a new bind to an exportable resource cc: mesa-stable Part-of: (cherry picked from commit 7b7a581a52db21ed8826d6f2986ea6dfc208fb2a) --- .pick_status.json | 2 +- src/gallium/drivers/zink/zink_resource.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 286bac55a5c..c3464bf255a 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -10364,7 +10364,7 @@ "description": "zink: prune dmabuf export tracking when adding resource binds", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index ae78836d15a..b2b85014855 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -1611,6 +1611,11 @@ add_resource_bind(struct zink_context *ctx, struct zink_resource *res, unsigned box.depth = util_num_layers(&res->base.b, i); ctx->base.resource_copy_region(&ctx->base, &res->base.b, i, 0, 0, 0, &staging.base.b, i, &box); } + if (old_obj->exportable) { + simple_mtx_lock(&ctx->batch.state->exportable_lock); + _mesa_set_remove_key(&ctx->batch.state->dmabuf_exports, &staging); + simple_mtx_unlock(&ctx->batch.state->exportable_lock); + } zink_resource_object_reference(screen, &old_obj, NULL); return true; }