From 76a329e55c34e2d60a0b1d92bf61bbf3baf5dd41 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 27 Feb 2023 14:41:37 +0100 Subject: [PATCH] xwayland: fix error path when modifier is not supported When the modifier is not supported by the compositor, and the DMA-BUF contains multiple planes, xwl_pixmap->buffer is NULL. Avoid crashing when calling wl_buffer_add_listener(). Signed-off-by: Simon Ser --- hw/xwayland/xwayland-glamor-gbm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c index 3984d0b38..2d42bbba3 100644 --- a/hw/xwayland/xwayland-glamor-gbm.c +++ b/hw/xwayland/xwayland-glamor-gbm.c @@ -446,8 +446,9 @@ xwl_glamor_gbm_get_wl_buffer_for_pixmap(PixmapPtr pixmap) close(prime_fds[i]); /* Add our listener now */ - wl_buffer_add_listener(xwl_pixmap->buffer, - &xwl_glamor_gbm_buffer_listener, pixmap); + if (xwl_pixmap->buffer) + wl_buffer_add_listener(xwl_pixmap->buffer, + &xwl_glamor_gbm_buffer_listener, pixmap); return xwl_pixmap->buffer; }