mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 11:28:05 +02:00
zink: Return early if the file descriptor could not have been duplicated/acquired
Do not continue and call drmIoctl on an invalid file descriptor.
Fix defect reported by Coverity Scan.
Argument cannot be negative
The negative argument will be interpreted as a very large unsigned value.
CID: 1544377
Cc: mesa-stable
Signed-off-by: Corentin Noël <corentin.noel@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27788>
(cherry picked from commit b6962bbfc8)
This commit is contained in:
parent
63ab36fe28
commit
ebed52c790
2 changed files with 7 additions and 2 deletions
|
|
@ -1444,7 +1444,7 @@
|
|||
"description": "zink: Return early if the file descriptor could not have been duplicated/acquired",
|
||||
"nominated": true,
|
||||
"nomination_type": 0,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -2277,7 +2277,7 @@ zink_screen_export_dmabuf_semaphore(struct zink_screen *screen, struct zink_reso
|
|||
.fd = -1,
|
||||
};
|
||||
|
||||
int fd;
|
||||
int fd = -1;
|
||||
if (res->obj->is_aux) {
|
||||
fd = os_dupfd_cloexec(res->obj->handle);
|
||||
} else {
|
||||
|
|
@ -2288,6 +2288,11 @@ zink_screen_export_dmabuf_semaphore(struct zink_screen *screen, struct zink_reso
|
|||
VKSCR(GetMemoryFdKHR)(screen->dev, &fd_info, &fd);
|
||||
}
|
||||
|
||||
if (unlikely(fd < 0)) {
|
||||
mesa_loge("MESA: Unable to get a valid memory fd");
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
int ret = drmIoctl(fd, DMA_BUF_IOCTL_EXPORT_SYNC_FILE, &export);
|
||||
if (ret) {
|
||||
if (errno == ENOTTY || errno == EBADF || errno == ENOSYS) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue