tu/kgsl: Fix memory leak of tmp allocations during submissions

cc: mesa-stable

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12805>
(cherry picked from commit 3ccd199708)
This commit is contained in:
Danylo Piliaiev 2023-08-10 15:36:33 +02:00 committed by Eric Engestrom
parent 15524986b8
commit 9fa7e28179
2 changed files with 17 additions and 3 deletions

View File

@ -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
},

View File

@ -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;
}