llvmpipe: make sure to duplicate the fd handle before giving out

This handle is given to the user to close, so make sure to dup it
first.

Fixes: d74ea2c117 ("llvmpipe: Implement dmabuf handling")
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Lucas Fryzek <lfryzek@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30839>
This commit is contained in:
Dave Airlie
2024-08-26 13:23:07 +10:00
committed by Marge Bot
parent 521dc42e6c
commit 4bf257a18f

View File

@@ -822,8 +822,9 @@ llvmpipe_resource_get_handle(struct pipe_screen *_screen,
lpr->data = lpr->dmabuf_alloc->cpu_addr;
/* reuse lavapipe codepath to handle destruction */
lpr->backable = true;
} else {
whandle->handle = os_dupfd_cloexec(lpr->dmabuf_alloc->dmabuf_fd);
}
whandle->handle = lpr->dmabuf_alloc->dmabuf_fd;
whandle->modifier = DRM_FORMAT_MOD_LINEAR;
whandle->stride = lpr->row_stride[0];
return true;