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>
(cherry picked from commit 4bf257a18f)
This commit is contained in:
Dave Airlie 2024-08-26 13:23:07 +10:00 committed by Eric Engestrom
parent 46695f7cca
commit f6da7d541b
2 changed files with 3 additions and 2 deletions

View File

@ -414,7 +414,7 @@
"description": "llvmpipe: make sure to duplicate the fd handle before giving out",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "d74ea2c117fe96e527471e572336f931c3c77da1",
"notes": null

View File

@ -761,8 +761,9 @@ llvmpipe_resource_get_handle(struct pipe_screen *_screen,
lpr->data = lpr->dmabuf_alloc->data;
/* 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;
return true;
} else if (!lpr->dt && whandle->type == WINSYS_HANDLE_TYPE_KMS) {
/* dri winsys code will use this to query the drm modifiers