Mesa (master): anv: fix memory leak on device destroy

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Oct 20 08:02:55 UTC 2019


Module: Mesa
Branch: master
Commit: b30e01aef5692be890f3f6ab944129b84d998254
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b30e01aef5692be890f3f6ab944129b84d998254

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Fri Oct 18 15:28:30 2019 +0300

anv: fix memory leak on device destroy

v2: handle vma destruction if vkCreateDevice fails (Jordan)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Gitlab: https://gitlab.freedesktop.org/mesa/mesa/issues/1959
Cc: <mesa-stable at lists.freedesktop.org>
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

---

 src/intel/vulkan/anv_device.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 37dabd76278..6d94cfc66ba 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -2515,7 +2515,7 @@ VkResult anv_CreateDevice(
                                           vk_priority_to_gen(priority));
       if (err != 0 && priority > VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT) {
          result = vk_error(VK_ERROR_NOT_PERMITTED_EXT);
-         goto fail_fd;
+         goto fail_vmas;
       }
    }
 
@@ -2684,6 +2684,11 @@ VkResult anv_CreateDevice(
    pthread_mutex_destroy(&device->mutex);
  fail_context_id:
    anv_gem_destroy_context(device, device->context_id);
+ fail_vmas:
+   if (physical_device->use_softpin) {
+      util_vma_heap_finish(&device->vma_hi);
+      util_vma_heap_finish(&device->vma_lo);
+   }
  fail_fd:
    close(device->fd);
  fail_device:
@@ -2739,6 +2744,11 @@ void anv_DestroyDevice(
 
    anv_bo_pool_finish(&device->batch_bo_pool);
 
+   if (physical_device->use_softpin) {
+      util_vma_heap_finish(&device->vma_hi);
+      util_vma_heap_finish(&device->vma_lo);
+   }
+
    pthread_cond_destroy(&device->queue_submit);
    pthread_mutex_destroy(&device->mutex);
 




More information about the mesa-commit mailing list