anv: Fix a potential BO handle leak
authorJason Ekstrand <jason@jlekstrand.net>
Fri, 25 Oct 2019 20:42:22 +0000 (15:42 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Thu, 31 Oct 2019 13:46:08 +0000 (13:46 +0000)
Fixes: 731c4adcf9b "anv/allocator: Add support for non-userptr"
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/vulkan/anv_allocator.c

index 7cfca6ea808ca3b9cf92f5c1407a9d263cd8d3f1..80c2c6f33683df842715bb23fae262ec3748a6fd 100644 (file)
@@ -534,9 +534,11 @@ anv_block_pool_expand_range(struct anv_block_pool *pool,
    if (use_softpin) {
       gem_handle = anv_gem_create(pool->device, newbo_size);
       map = anv_gem_mmap(pool->device, gem_handle, 0, newbo_size, 0);
-      if (map == MAP_FAILED)
+      if (map == MAP_FAILED) {
+         anv_gem_close(pool->device, gem_handle);
          return vk_errorf(pool->device->instance, pool->device,
                           VK_ERROR_MEMORY_MAP_FAILED, "gem mmap failed: %m");
+      }
       assert(center_bo_offset == 0);
    } else {
       /* Just leak the old map until we destroy the pool.  We can't munmap it