From fb0123f42ed099e348ca2ec7a55f20ba3570c9d4 Mon Sep 17 00:00:00 2001 From: johniyoods Date: Wed, 13 May 2026 12:08:19 +0530 Subject: [PATCH] egl/dri2: require valid render fd before advertising EGL_WL_bind_wayland_display Commit 718ef151f2e1 removed the legacy non-dmabuf wl_drm path and now gates the extension on has_dmabuf_import && has_dmabuf_export. These flags reflect driver capability and do not depend on whether a valid DRM render fd was assigned during display initialization. Before commit 718ef151f2e1, dri2_get_capabilities() returned 0 for kms_swrast paths because can_share_buffer is false there, so the __DRI_IMAGE_CAP_GLOBAL_NAMES check naturally excluded software-only devices. The replacement dmabuf flags do not have this property. On a software-only device (e.g., vgem), fd_render_gpu stays -1 and device_name is NULL, yet both dmabuf flags are true, causing the extension to be incorrectly advertised. When a Wayland compositor calls eglBindWaylandDisplayWL(), drmGetRenderDeviceNameFromFd(-1) returns NULL and strdup(device_name) is called on a NULL pointer, causing a SIGSEGV. Add an additional guard when setting WL_bind_wayland_display, so the extension is only advertised when a valid DRM render fd is present Fixes: 718ef151f2e1 ("egl/wayland: Remove support for non-dmabuf wl_drm") Signed-off-by: johniyoods Part-of: --- src/egl/drivers/dri2/egl_dri2.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index 4ee70dfae18..aa5692ab1ae 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -598,6 +598,7 @@ dri2_set_WL_bind_wayland_display(_EGLDisplay *disp) struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); disp->Extensions.WL_bind_wayland_display = + dri2_dpy->fd_render_gpu >= 0 && dri2_dpy->has_dmabuf_import && dri2_dpy->has_dmabuf_export; #endif }