From 222487fabeebfdfc3ec6cb4126ef484e5aacc1e5 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 19 Dec 2021 19:10:21 -0800 Subject: [PATCH] radv: Fix memory leak on error path. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix defects reported by Coverity Scan. Resource leak (RESOURCE_LEAK) leaked_storage: Variable signal_semaphore_infos going out of scope leaks the storage it points to leaked_storage: Variable wait_semaphore_infos going out of scope leaks the storage it points to. Fixes: 3da7d10d9bb ("radv: implement vkQueueSubmit2KHR()") Signed-off-by: Vinson Lee Reviewed-by: Daniel Schürmann Reviewed-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_device.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index d5fb9ad0555..be5004b00b5 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -5747,8 +5747,11 @@ radv_QueueBindSparse(VkQueue _queue, uint32_t bindInfoCount, const VkBindSparseI VkSemaphoreSubmitInfoKHR *signal_semaphore_infos = malloc(sizeof(*signal_semaphore_infos) * pBindInfo[i].signalSemaphoreCount); - if (!wait_semaphore_infos || !signal_semaphore_infos) + if (!wait_semaphore_infos || !signal_semaphore_infos) { + free(wait_semaphore_infos); + free(signal_semaphore_infos); return VK_ERROR_OUT_OF_HOST_MEMORY; + } for (uint32_t j = 0; j < pBindInfo[i].waitSemaphoreCount; j++) { wait_semaphore_infos[j] = (VkSemaphoreSubmitInfoKHR) {