Module: Mesa
Branch: staging/23.1
Commit: 9fa7e28179b758be97fb008024e46ab82a2194bf
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9fa7e28179b758be97fb008024e46ab82a2194bf

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 840767d4079..c832f4478ca 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -310,7 +310,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
     },
diff --git a/src/freedreno/vulkan/tu_knl_kgsl.cc 
b/src/freedreno/vulkan/tu_knl_kgsl.cc
index 34627f29d7d..31425651656 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;
    }
 
    queue->last_submit_timestamp = 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;
 }
 

Reply via email to