From 8bbe55533f536be74abfd4d1d59e5df4ad1a4ca7 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Sat, 17 Apr 2021 07:00:06 +0000 Subject: [PATCH] venus: close the import memory fd on success VkImportMemoryFdInfoKHR takes fd ownership on a successful import. Internally, vn_renderer_bo_create_dmabuf doesn't rely on the fd to extend the life cycle of the bo or the host resource, and it won't close the fd. Thus, we shall close the fd when the import succeeds. Signed-off-by: Yiwei Zhang Reviewed-by: Chia-I Wu Part-of: --- src/virtio/vulkan/vn_device_memory.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/virtio/vulkan/vn_device_memory.c b/src/virtio/vulkan/vn_device_memory.c index 1a2434e..8ea53c6 100644 --- a/src/virtio/vulkan/vn_device_memory.c +++ b/src/virtio/vulkan/vn_device_memory.c @@ -243,6 +243,8 @@ vn_AllocateMemory(VkDevice device, return vn_error(dev->instance, result); } + /* need to close import fd on success to avoid fd leak */ + close(import_info->fd); mem->base_bo = bo; } else if (suballocate) { result = vn_device_memory_pool_alloc( -- 2.7.4