From: Vivek Kasireddy Date: Tue, 17 Jun 2025 04:32:25 +0000 (-0700) Subject: ui/egl-helpers: Error check the fds in egl_dmabuf_export_texture() X-Git-Tag: v10.1.0-rc0~16^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46c798f0471ca341ce607b5ca15f76b001712f3f;p=thirdparty%2Fqemu.git ui/egl-helpers: Error check the fds in egl_dmabuf_export_texture() While trying to export and obtain fds associated with a texture, it is possible that the fds returned after eglExportDMABUFImageMESA() call have error values. Therefore, we need to evaluate the value of all fds and return false if any of them are negative. Cc: Gerd Hoffmann Cc: Marc-André Lureau Cc: Dmitry Osipenko Cc: Frediano Ziglio Cc: Dongwon Kim Cc: Michael Scherle Reviewed-by: Marc-André Lureau Signed-off-by: Vivek Kasireddy Message-Id: <20250617043546.1022779-2-vivek.kasireddy@intel.com> --- diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 5503a795e4..e3f2872cc1 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -295,6 +295,7 @@ bool egl_dmabuf_export_texture(uint32_t tex_id, int *fd, EGLint *offset, { EGLImageKHR image; EGLuint64KHR modifiers[DMABUF_MAX_PLANES]; + int i; image = eglCreateImageKHR(qemu_egl_display, eglGetCurrentContext(), EGL_GL_TEXTURE_2D_KHR, @@ -314,6 +315,11 @@ bool egl_dmabuf_export_texture(uint32_t tex_id, int *fd, EGLint *offset, *modifier = modifiers[0]; } + for (i = 0; i < *num_planes; i++) { + if (fd[i] < 0) { + return false; + } + } return true; }