egl/dri2: require valid render fd before advertising EGL_WL_bind_wayland_display

Commit 718ef151f2 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 718ef151f2, 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: 718ef151f2 ("egl/wayland: Remove support for non-dmabuf wl_drm")

Signed-off-by: johniyoods <johniyoods@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41527>
This commit is contained in:
johniyoods 2026-05-13 12:08:19 +05:30 committed by Marge Bot
parent 171210e36a
commit fb0123f42e

View file

@ -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
}