Commit 05e19644 authored by Hans De Goede's avatar Hans De Goede Committed by Adam Jackson

glamor: Trust eglGetPlatformDisplayEXT if it exists

If the libEGL we are using has eglGetPlatformDisplayEXT, yet it still
returns NULL, then this very likely means that it does not support the
type (e.g. EGL_PLATFORM_GBM_MESA) passed in, and then returning NULL is
the right thing to do.

This avoids falling back to an eglGetDisplay() implementation which does
not understands the passed in gbm handle, treats it as a pointer to
something else completely, followed by a crash sooner or later.

Specifically this fixes using the nvidia binary driver, with nvidia's
libEGL + the modesetting driver on a secondary GPU crashing inside
glamor_egl_init() sometimes.

Cc: Eric Anholt <>
Reviewed-by: Adam Jackson's avatarAdam Jackson <>
Signed-off-by: default avatarHans de Goede <>
parent 5b74e260
......@@ -769,6 +769,10 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
glamor_egl->display = glamor_egl_get_display(EGL_PLATFORM_GBM_MESA,
if (!glamor_egl->display) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglGetDisplay() failed\n");
goto error;
glamor_egl->display = eglGetDisplay((EGLNativeDisplayType) (intptr_t) fd);
......@@ -67,9 +67,7 @@ glamor_egl_get_display(EGLint type, void *native)
(void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
if (getPlatformDisplayEXT)
dpy = getPlatformDisplayEXT(type, native, NULL);
if (dpy)
return dpy;
return getPlatformDisplayEXT(type, native, NULL);
/* Welp, everything is awful. */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment