llvmpipe: Close mem_fd or dmabuf_fd on error

The variable shadowing made the error path to leak these file descriptors.

CID: 1596485, 1596493 Logically dead code
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35091>
This commit is contained in:
Corentin Noël
2025-05-20 17:11:35 +02:00
committed by Marge Bot
parent fb72e84c7a
commit 94f2d53586
+4 -4
View File
@@ -1388,7 +1388,7 @@ llvmpipe_resource_alloc_udmabuf(struct llvmpipe_screen *screen,
size = align(size, alignment);
int mem_fd = memfd_create("lp_dma_buf", MFD_ALLOW_SEALING);
mem_fd = memfd_create("lp_dma_buf", MFD_ALLOW_SEALING);
if (mem_fd == -1)
goto fail;
@@ -1409,7 +1409,7 @@ llvmpipe_resource_alloc_udmabuf(struct llvmpipe_screen *screen,
.size = size
};
int dmabuf_fd = ioctl(screen->udmabuf_fd, UDMABUF_CREATE, &create);
dmabuf_fd = ioctl(screen->udmabuf_fd, UDMABUF_CREATE, &create);
if (dmabuf_fd < 0)
goto fail;
@@ -1426,10 +1426,10 @@ llvmpipe_resource_alloc_udmabuf(struct llvmpipe_screen *screen,
}
fail:
if (dmabuf_fd >= 0)
close(dmabuf_fd);
if (mem_fd != -1)
close(mem_fd);
if (dmabuf_fd != -1)
close(dmabuf_fd);
/* If we don't have access to the udmabuf device
* or something else fails we return NULL */
return NULL;