From bce2cb1e24b6e8ee85db52e5d9430095c045ae2a Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Fri, 5 Sep 2025 13:48:46 -0700 Subject: [PATCH] anv: Refactor anv_shader_compile result handling Acked-by: Kenneth Graunke Acked-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_shader_compile.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/intel/vulkan/anv_shader_compile.c b/src/intel/vulkan/anv_shader_compile.c index e44ec68654e..20ff60b808f 100644 --- a/src/intel/vulkan/anv_shader_compile.c +++ b/src/intel/vulkan/anv_shader_compile.c @@ -1868,7 +1868,7 @@ anv_shader_compile(struct vk_device *vk_device, result = vk_errorf(device, VK_ERROR_UNKNOWN, "%s", error_str); else result = vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); - goto fail; + goto end; } anv_nir_validate_push_layout(device->physical, @@ -1881,9 +1881,11 @@ anv_shader_compile(struct vk_device *vk_device, mem_ctx, shader_data, pAllocator, shader_data->shader_out); if (result != VK_SUCCESS) - goto fail; + goto end; } +end: + ralloc_free(mem_ctx); #if 0 @@ -1893,14 +1895,11 @@ anv_shader_compile(struct vk_device *vk_device, } #endif - return VK_SUCCESS; - -fail: - ralloc_free(mem_ctx); - - for (unsigned s = 0; s < shader_count; s++) { - if (shaders_out[s] != NULL) - vk_shader_free(vk_device, &vk_device->alloc, shaders_out[s]); + if (result != VK_SUCCESS) { + for (unsigned s = 0; s < shader_count; s++) { + if (shaders_out[s] != NULL) + vk_shader_free(vk_device, &vk_device->alloc, shaders_out[s]); + } } return result;