anv: Fix close(fd) before import issue in vkCreateDmaBufImageINTEL
authorKevin Strasser <kevin.strasser@intel.com>
Tue, 3 Apr 2018 21:21:34 +0000 (14:21 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 4 Apr 2018 01:33:17 +0000 (18:33 -0700)
If we close the fd before calling DRM_IOCTL_PRIME_FD_TO_HANDLE the kernel
will hit a -EBADF error. Move the close(fd) call to the end of
anv_CreateDmaBufImageINTEL().

Signed-off-by: Kevin Strasser <kevin.strasser@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/vulkan/anv_intel.c

index 82373f0c91d07387904bcd56d0de1d99ef6d5081..976c83308e31ecc664cd154d7674ab9986aed37f 100644 (file)
@@ -71,8 +71,6 @@ VkResult anv_CreateDmaBufImageINTEL(
    if (result != VK_SUCCESS)
       goto fail;
 
-   close(pCreateInfo->fd);
-
    image = anv_image_from_handle(image_h);
 
    result = anv_bo_cache_import(device, &device->bo_cache,
@@ -105,6 +103,8 @@ VkResult anv_CreateDmaBufImageINTEL(
    *pMem = anv_device_memory_to_handle(mem);
    *pImage = anv_image_to_handle(image);
 
+   close(pCreateInfo->fd);
+
    return VK_SUCCESS;
 
  fail_import: