From 591afd1d52b37c8ec29c86e3e7900c11610bb64e Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 5 Oct 2021 10:34:01 -0700 Subject: [PATCH] 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: --- 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; }