Module: Mesa
Branch: main
Commit: 79c75a3e973ff491e5d1c1957433634e9d90d933
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=79c75a3e973ff491e5d1c1957433634e9d90d933

Author: Chia-I Wu <[email protected]>
Date:   Wed Sep  7 18:41:48 2022 -0700

turnip: fix error handling for tu_queue_init

tu_queue_finish can only be called on initialized queues.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18510>

---

 src/freedreno/vulkan/tu_device.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c
index 992a6c9053c..2f76ae222f5 100644
--- a/src/freedreno/vulkan/tu_device.c
+++ b/src/freedreno/vulkan/tu_device.c
@@ -1856,8 +1856,10 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
       for (unsigned q = 0; q < queue_create->queueCount; q++) {
          result = tu_queue_init(device, &device->queues[qfi][q], q,
                                 queue_create);
-         if (result != VK_SUCCESS)
+         if (result != VK_SUCCESS) {
+            device->queue_count[qfi] = q;
             goto fail_queues;
+         }
       }
    }
 
@@ -2056,7 +2058,7 @@ fail_queues:
    for (unsigned i = 0; i < TU_MAX_QUEUE_FAMILIES; i++) {
       for (unsigned q = 0; q < device->queue_count[i]; q++)
          tu_queue_finish(&device->queues[i][q]);
-      if (device->queue_count[i])
+      if (device->queues[i])
          vk_free(&device->vk.alloc, device->queues[i]);
    }
 

Reply via email to