Mesa (main): turnip: Free disk cache on pdev init failure.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Oct 6 17:09:50 UTC 2021


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

Author: Emma Anholt <emma at anholt.net>
Date:   Tue Oct  5 10:34:01 2021 -0700

turnip: Free disk cache on pdev init failure.

Noticed while debugging test failure under valgrind (the disk cache
doesn't come from the vulkan allocator, so we could leak it and not fail
the test).

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

---

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

diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c
index 54f66c00d48..967c957a9e1 100644
--- a/src/freedreno/vulkan/tu_device.c
+++ b/src/freedreno/vulkan/tu_device.c
@@ -221,7 +221,7 @@ tu_physical_device_init(struct tu_physical_device *device,
    if (!info) {
       result = vk_startup_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
                                  "device %s is unsupported", device->name);
-      goto fail;
+      goto fail_free_name;
    }
    switch (fd_dev_gen(&device->dev_id)) {
    case 6:
@@ -233,12 +233,12 @@ tu_physical_device_init(struct tu_physical_device *device,
    default:
       result = vk_startup_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
                                  "device %s is unsupported", device->name);
-      goto fail;
+      goto fail_free_name;
    }
    if (tu_device_get_cache_uuid(fd_dev_gpu_id(&device->dev_id), device->cache_uuid)) {
       result = vk_startup_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
                                  "cannot generate UUID");
-      goto fail;
+      goto fail_free_name;
    }
 
    /* The gpu id is already embedded in the uuid so we just pass "tu"
@@ -264,20 +264,22 @@ tu_physical_device_init(struct tu_physical_device *device,
                                     &supported_extensions,
                                     &dispatch_table);
    if (result != VK_SUCCESS)
-      goto fail;
+      goto fail_free_cache;
 
 #if TU_HAS_SURFACE
    result = tu_wsi_init(device);
    if (result != VK_SUCCESS) {
       vk_startup_errorf(instance, result, "WSI init failure");
       vk_physical_device_finish(&device->vk);
-      goto fail;
+      goto fail_free_cache;
    }
 #endif
 
    return VK_SUCCESS;
 
-fail:
+fail_free_cache:
+   disk_cache_destroy(device->disk_cache);
+fail_free_name:
    vk_free(&instance->vk.alloc, (void *)device->name);
    return result;
 }



More information about the mesa-commit mailing list