From 95944e2b990dacde81892406c8a0e2cc2afa7b3e Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Thu, 28 Jul 2022 22:52:15 +0200 Subject: [PATCH] glamor_egl: handle fd export failure in glamor_egl_fds_from_pixmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check the fd for validity before giving a success return code. Signed-off-by: Lucas Stach Reviewed-by: Simon Ser Tested-by: Guido Günther --- glamor/glamor_egl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c index 60d0df893..fa5fcbd04 100644 --- a/glamor/glamor_egl.c +++ b/glamor/glamor_egl.c @@ -417,6 +417,11 @@ glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds, num_fds = gbm_bo_get_plane_count(bo); for (i = 0; i < num_fds; i++) { fds[i] = gbm_bo_get_fd(bo); + if (fds[i] == -1) { + while (--i >= 0) + close(fds[i]); + return 0; + } strides[i] = gbm_bo_get_stride_for_plane(bo, i); offsets[i] = gbm_bo_get_offset(bo, i); } @@ -424,6 +429,8 @@ glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds, #else num_fds = 1; fds[0] = gbm_bo_get_fd(bo); + if (fds[0] == -1) + return 0; strides[0] = gbm_bo_get_stride(bo); offsets[0] = 0; *modifier = DRM_FORMAT_MOD_INVALID;