Mesa (main): venus: fix the queue init failure path

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 16 19:06:12 UTC 2022


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

Author: Yiwei Zhang <zzyiwei at chromium.org>
Date:   Fri May 20 20:47:32 2022 +0000

venus: fix the queue init failure path

The prior behavior can ignore certain failure result, and might also
clean up queues that are never initialized.

Fixes: ddd75330559 ("venus: initial support for queue/fence/semaphore")

Signed-off-by: Yiwei Zhang <zzyiwei at chromium.org>
Reviewed-by: Chad Versace <chadversary at chromium.org>
Reviewed-by: Ryan Neph <ryanneph at google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16731>

---

 src/virtio/vulkan/vn_device.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/virtio/vulkan/vn_device.c b/src/virtio/vulkan/vn_device.c
index 14cc2efe9ad..6e04afbd4a0 100644
--- a/src/virtio/vulkan/vn_device.c
+++ b/src/virtio/vulkan/vn_device.c
@@ -89,28 +89,26 @@ vn_device_init_queues(struct vn_device *dev,
    if (!queues)
       return VK_ERROR_OUT_OF_HOST_MEMORY;
 
-   VkResult result = VK_SUCCESS;
    count = 0;
    for (uint32_t i = 0; i < create_info->queueCreateInfoCount; i++) {
+      VkResult result;
+
       const VkDeviceQueueCreateInfo *queue_info =
          &create_info->pQueueCreateInfos[i];
       for (uint32_t j = 0; j < queue_info->queueCount; j++) {
          result = vn_queue_init(dev, &queues[count], queue_info, j);
-         if (result != VK_SUCCESS)
-            break;
+         if (result != VK_SUCCESS) {
+            for (uint32_t k = 0; k < count; k++)
+               vn_queue_fini(&queues[k]);
+            vk_free(alloc, queues);
+
+            return result;
+         }
 
          count++;
       }
    }
 
-   if (result != VK_SUCCESS) {
-      for (uint32_t i = 0; i < count; i++)
-         vn_queue_fini(&queues[i]);
-      vk_free(alloc, queues);
-
-      return result;
-   }
-
    dev->queues = queues;
    dev->queue_count = count;
 



More information about the mesa-commit mailing list