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>
This commit is contained in:
@@ -2367,7 +2367,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 {
|
||||
@@ -2378,6 +2378,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) {
|
||||
|
Reference in New Issue
Block a user