Coverity points out that we can pass a negative value to `close()`,
which results in an unchecked error. While this is technically true, it
really isn't a problem as `close()` is speced to return -1 in that case
(which we ignore). However, what is true is that if we fail to dup the
fd (the only case where we could end up with a negative value), then
we're in an unrecoverable error state anyway, and should go to the error
cleanup code.
CID: 1521539
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Marcin Ĺšlusarz <marcin.slusarz@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21568>
* fd so that its namespace does not clash with another.
*/
bufmgr->fd = os_dupfd_cloexec(fd);
+ if (bufmgr->fd == -1)
+ goto error_dup;
p_atomic_set(&bufmgr->refcount, 1);
}
error_engine_info:
close(bufmgr->fd);
+error_dup:
free(bufmgr);
return NULL;
}