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

Author: Jason Ekstrand <[email protected]>
Date:   Tue Feb  8 16:04:34 2022 -0600

anv: Call vk_command_buffer_finish if create fails

This wasn't much of a problem before because vk_command_buffer_finish()
doesn't do much on an empty command buffer.  However, it's about to be
responsible for managing the pool's list of command buffers so it will
be critical to get this right.

Fixes: c9189f481353 ("anv: Use a common vk_command_buffer structure")
Reviewed-by: Lionel Landwerlin <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14917>

---

 src/intel/vulkan/anv_cmd_buffer.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/intel/vulkan/anv_cmd_buffer.c 
b/src/intel/vulkan/anv_cmd_buffer.c
index 4d3b1d28a4c..73d3ece7355 100644
--- a/src/intel/vulkan/anv_cmd_buffer.c
+++ b/src/intel/vulkan/anv_cmd_buffer.c
@@ -277,7 +277,7 @@ static VkResult anv_create_cmd_buffer(
 
    result = vk_command_buffer_init(&cmd_buffer->vk, &device->vk);
    if (result != VK_SUCCESS)
-      goto fail;
+      goto fail_alloc;
 
    cmd_buffer->batch.status = VK_SUCCESS;
 
@@ -287,7 +287,7 @@ static VkResult anv_create_cmd_buffer(
 
    result = anv_cmd_buffer_init_batch_bo_chain(cmd_buffer);
    if (result != VK_SUCCESS)
-      goto fail;
+      goto fail_vk;
 
    anv_state_stream_init(&cmd_buffer->surface_state_stream,
                          &device->surface_state_pool, 4096);
@@ -310,7 +310,9 @@ static VkResult anv_create_cmd_buffer(
 
    return VK_SUCCESS;
 
- fail:
+ fail_vk:
+   vk_command_buffer_finish(&cmd_buffer->vk);
+ fail_alloc:
    vk_free2(&device->vk.alloc, &pool->alloc, cmd_buffer);
 
    return result;

Reply via email to