zink: destroy batch states after copy context

the copy context contains its own batch states, so these must
not be destroyed yet

Fixes: b06f6e00fb ("zink: fix heap-use-after-free on batch_state with sub-allocated pipe_resources")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28118>
(cherry picked from commit 7fd12a446d)
This commit is contained in:
Mike Blumenkrantz 2024-03-11 10:05:01 -04:00 committed by Eric Engestrom
parent 2eb71d157c
commit 7f56248fa7
2 changed files with 8 additions and 7 deletions

View file

@ -1694,7 +1694,7 @@
"description": "zink: destroy batch states after copy context",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "b06f6e00fba6e33c28a198a1bb14b89e9dfbb4ae",
"notes": null

View file

@ -1466,12 +1466,6 @@ static void
zink_destroy_screen(struct pipe_screen *pscreen)
{
struct zink_screen *screen = zink_screen(pscreen);
struct zink_batch_state *bs = screen->free_batch_states;
while (bs) {
struct zink_batch_state *bs_next = bs->next;
zink_batch_state_destroy(screen, bs);
bs = bs_next;
}
#ifdef HAVE_RENDERDOC_APP_H
if (screen->renderdoc_capture_all && p_atomic_dec_zero(&num_screens))
@ -1484,6 +1478,13 @@ zink_destroy_screen(struct pipe_screen *pscreen)
if (screen->copy_context)
screen->copy_context->base.destroy(&screen->copy_context->base);
struct zink_batch_state *bs = screen->free_batch_states;
while (bs) {
struct zink_batch_state *bs_next = bs->next;
zink_batch_state_destroy(screen, bs);
bs = bs_next;
}
if (VK_NULL_HANDLE != screen->debugUtilsCallbackHandle) {
VKSCR(DestroyDebugUtilsMessengerEXT)(screen->instance, screen->debugUtilsCallbackHandle, NULL);
}