zink: fix descriptor pool free iterating

these arrays are sparsely allocated, and using pop() on them will
fail to access some elements

Fixes: cf7c17a7af ("zink: rework descriptor pool overflow")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21246>
This commit is contained in:
Mike Blumenkrantz 2023-02-10 09:36:30 -05:00 committed by Marge Bot
parent 16c019142b
commit ffd91ee7a8

View file

@ -1406,11 +1406,11 @@ void
zink_batch_descriptor_deinit(struct zink_screen *screen, struct zink_batch_state *bs)
{
for (unsigned i = 0; i < ZINK_DESCRIPTOR_BASE_TYPES; i++) {
while (util_dynarray_contains(&bs->dd.pools[i], struct zink_descriptor_pool_multi *)) {
struct zink_descriptor_pool_multi *mpool = util_dynarray_pop(&bs->dd.pools[i], struct zink_descriptor_pool_multi *);
if (mpool) {
deinit_multi_pool_overflow(screen, mpool);
multi_pool_destroy(screen, mpool);
for (unsigned j = 0; j < bs->dd.pools[i].capacity / sizeof(struct zink_descriptor_pool_multi *); j++) {
struct zink_descriptor_pool_multi **mppool = util_dynarray_element(&bs->dd.pools[i], struct zink_descriptor_pool_multi *, j);
if (mppool && *mppool) {
deinit_multi_pool_overflow(screen, *mppool);
multi_pool_destroy(screen, *mppool);
}
}
util_dynarray_fini(&bs->dd.pools[i]);