lavapipe: do not close import fd on error and amend an error code

The implementation only takes the ownership after a successful import.
On import failure, the caller is going to handle the fd. Meanwhile,
amend a missing error code on an error path.

Fixes: 895d3399f7 ("lavapipe: add support for KHR_external_memory_fd")
Reviewed-by: Lucas Fryzek <lfryzek@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36204>
This commit is contained in:
Yiwei Zhang 2025-07-17 20:08:46 -07:00 committed by Marge Bot
parent f1af533b2c
commit 160cd3a317

View file

@ -2054,13 +2054,12 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_AllocateMemory(
bool dmabuf = import_info->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT;
uint64_t size;
if(!device->pscreen->import_memory_fd(device->pscreen, import_info->fd, &mem->pmem, &size, dmabuf)) {
close(import_info->fd);
error = VK_ERROR_INVALID_EXTERNAL_HANDLE;
goto fail;
}
if(size < pAllocateInfo->allocationSize) {
device->pscreen->free_memory_fd(device->pscreen, mem->pmem);
close(import_info->fd);
error = VK_ERROR_INVALID_EXTERNAL_HANDLE;
goto fail;
}
if (export_info && export_info->handleTypes == import_info->handleType) {