From 951502e49797ab4c5db047e9df32c93d050d64af Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Thu, 28 Jul 2022 22:44:59 +0200 Subject: [PATCH] xwayland: 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 --- hw/xwayland/xwayland-glamor-gbm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c index 60c63ba99..adefc768b 100644 --- a/hw/xwayland/xwayland-glamor-gbm.c +++ b/hw/xwayland/xwayland-glamor-gbm.c @@ -628,6 +628,11 @@ glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds, for (i = 0; i < num_fds; i++) { fds[i] = gbm_bo_get_fd(xwl_pixmap->bo); + if (fds[i] == -1) { + while (--i >= 0) + close(fds[i]); + return 0; + } strides[i] = gbm_bo_get_stride_for_plane(xwl_pixmap->bo, i); offsets[i] = gbm_bo_get_offset(xwl_pixmap->bo, i); } @@ -636,6 +641,8 @@ glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds, #else *modifier = DRM_FORMAT_MOD_INVALID; fds[0] = gbm_bo_get_fd(xwl_pixmap->bo); + if (fds[0] == -1) + return 0; strides[0] = gbm_bo_get_stride(xwl_pixmap->bo); offsets[0] = 0; return 1;