ui/gtk: Check if fence_fd is equal to or greater than 0

'fence_fd' needs to be validated always before being referenced
And the passing condition should include '== 0' as 0 is a valid
value for the file descriptor.

Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
Cc: Daniel P. Berrangé <berrange@redhat.com>
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
Message-Id: <20240508175403.3399895-2-dongwon.kim@intel.com>
This commit is contained in:
Dongwon Kim 2024-05-08 10:53:58 -07:00 committed by Marc-André Lureau
parent 77bf310084
commit e4e62514e3
3 changed files with 8 additions and 6 deletions

View File

@ -99,7 +99,7 @@ void gd_egl_draw(VirtualConsole *vc)
#ifdef CONFIG_GBM
if (dmabuf) {
egl_dmabuf_create_fence(dmabuf);
if (dmabuf->fence_fd > 0) {
if (dmabuf->fence_fd >= 0) {
qemu_set_fd_handler(dmabuf->fence_fd, gd_hw_gl_flushed, NULL, vc);
return;
}

View File

@ -86,7 +86,7 @@ void gd_gl_area_draw(VirtualConsole *vc)
#ifdef CONFIG_GBM
if (dmabuf) {
egl_dmabuf_create_fence(dmabuf);
if (dmabuf->fence_fd > 0) {
if (dmabuf->fence_fd >= 0) {
qemu_set_fd_handler(dmabuf->fence_fd, gd_hw_gl_flushed, NULL, vc);
return;
}

View File

@ -597,10 +597,12 @@ void gd_hw_gl_flushed(void *vcon)
VirtualConsole *vc = vcon;
QemuDmaBuf *dmabuf = vc->gfx.guest_fb.dmabuf;
qemu_set_fd_handler(dmabuf->fence_fd, NULL, NULL, NULL);
close(dmabuf->fence_fd);
dmabuf->fence_fd = -1;
graphic_hw_gl_block(vc->gfx.dcl.con, false);
if (dmabuf->fence_fd >= 0) {
qemu_set_fd_handler(dmabuf->fence_fd, NULL, NULL, NULL);
close(dmabuf->fence_fd);
dmabuf->fence_fd = -1;
graphic_hw_gl_block(vc->gfx.dcl.con, false);
}
}
/** DisplayState Callbacks (opengl version) **/