Module: Mesa Branch: staging/23.2 Commit: 4b6322f1c6606bab4b051f59e86d6d54221ab952 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4b6322f1c6606bab4b051f59e86d6d54221ab952
Author: Danylo Piliaiev <[email protected]> Date: Thu Aug 10 15:36:33 2023 +0200 tu/kgsl: Fix memory leak of tmp allocations during submissions cc: mesa-stable Signed-off-by: Danylo Piliaiev <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12805> (cherry picked from commit 3ccd199708e5fd8c0d3cd4d266f88cbad3c1fa3d) --- .pick_status.json | 2 +- src/freedreno/vulkan/tu_knl_kgsl.cc | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 3fe319990c3..f8d738a78fa 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1764,7 +1764,7 @@ "description": "tu/kgsl: Fix memory leak of tmp allocations during submissions", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/freedreno/vulkan/tu_knl_kgsl.cc b/src/freedreno/vulkan/tu_knl_kgsl.cc index 004abae939c..210875a0f41 100644 --- a/src/freedreno/vulkan/tu_knl_kgsl.cc +++ b/src/freedreno/vulkan/tu_knl_kgsl.cc @@ -1120,8 +1120,7 @@ kgsl_queue_submit(struct tu_queue *queue, struct vk_queue_submit *vk_submit) if (ret) { result = vk_device_set_lost(&queue->device->vk, "submit failed: %s\n", strerror(errno)); - pthread_mutex_unlock(&queue->device->submit_mutex); - return result; + goto fail_submit; } p_atomic_set(&queue->fence, req.timestamp); @@ -1140,6 +1139,21 @@ kgsl_queue_submit(struct tu_queue *queue, struct vk_queue_submit *vk_submit) pthread_mutex_unlock(&queue->device->submit_mutex); pthread_cond_broadcast(&queue->device->timeline_cond); + if (cmd_buffers != (struct tu_cmd_buffer **) vk_submit->command_buffers) + vk_free(&queue->device->vk.alloc, cmd_buffers); + + vk_free(&queue->device->vk.alloc, cmds); + + return VK_SUCCESS; + +fail_submit: + pthread_mutex_unlock(&queue->device->submit_mutex); + + if (cmd_buffers != (struct tu_cmd_buffer **) vk_submit->command_buffers) + vk_free(&queue->device->vk.alloc, cmd_buffers); + + vk_free(&queue->device->vk.alloc, cmds); + return result; }
