zink: Do not access just freed zink_batch_state

Cc: mesa-stable
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13370>
(cherry picked from commit 4d777631b5)
This commit is contained in:
Witold Baryluk 2021-10-15 00:29:47 +02:00 committed by Eric Engestrom
parent 9c7e483a1c
commit 8876a87565
2 changed files with 5 additions and 2 deletions

View file

@ -1678,7 +1678,7 @@
"description": "zink: Do not access just freed zink_batch_state",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -105,9 +105,12 @@ zink_context_destroy(struct pipe_context *pctx)
simple_mtx_destroy(&ctx->batch_mtx);
zink_clear_batch_state(ctx, ctx->batch.state);
zink_batch_state_destroy(screen, ctx->batch.state);
for (struct zink_batch_state *bs = ctx->batch_states; bs; bs = bs->next) {
struct zink_batch_state *bs = ctx->batch_states;
while (bs) {
struct zink_batch_state *bs_next = bs->next;
zink_clear_batch_state(ctx, bs);
zink_batch_state_destroy(screen, bs);
bs = bs_next;
}
util_dynarray_foreach(&ctx->free_batch_states, struct zink_batch_state*, bs) {
zink_clear_batch_state(ctx, *bs);