Mesa (main): radv: Fix memory leak on error path.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Dec 24 08:40:38 UTC 2021


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

Author: Vinson Lee <vlee at freedesktop.org>
Date:   Sun Dec 19 19:10:21 2021 -0800

radv: Fix memory leak on error path.

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 <vlee at freedesktop.org>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14260>

---

 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) {



More information about the mesa-commit mailing list