panvk: Don't call queue_finish() on non-initialized queues

panvk_per_arch(queue_init)() can fail, and we need to undo the
initialization only on queues that were properly initialized.

In order to do that, increment queue_count only after the
initialization succeeds, and adjust the test in the error path to not
leave an allocated but non-initialized panvk_queue object behind.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31382>
This commit is contained in:
Boris Brezillon 2024-09-27 15:02:42 +02:00 committed by Marge Bot
parent 904cf2b189
commit bea7c59113

View file

@ -350,13 +350,13 @@ panvk_per_arch(create_device)(struct panvk_physical_device *physical_device,
memset(device->queues[qfi], 0,
queue_create->queueCount * sizeof(struct panvk_queue));
device->queue_count[qfi] = queue_create->queueCount;
for (unsigned q = 0; q < queue_create->queueCount; q++) {
result = panvk_per_arch(queue_init)(device, &device->queues[qfi][q], q,
queue_create);
if (result != VK_SUCCESS)
goto err_finish_queues;
device->queue_count[qfi]++;
}
}
@ -367,7 +367,7 @@ err_finish_queues:
for (unsigned i = 0; i < PANVK_MAX_QUEUE_FAMILIES; i++) {
for (unsigned q = 0; q < device->queue_count[i]; q++)
panvk_per_arch(queue_finish)(&device->queues[i][q]);
if (device->queue_count[i])
if (device->queues[i])
vk_object_free(&device->vk, NULL, device->queues[i]);
}