diff options
author | Hans De Goede <hdegoede@redhat.com> | 2016-12-20 13:00:43 +0100 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2017-01-02 13:07:25 -0500 |
commit | 05e19644250698aa126a60bc671e85425df784d1 (patch) | |
tree | 7a158267a161bfe510e817bcc823646675a7d9ca | |
parent | 5b74e260e009d8bdf26433724495802b85cce7c3 (diff) |
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 <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | glamor/glamor_egl.c | 4 | ||||
-rw-r--r-- | glamor/glamor_egl.h | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c index 9cc0f8d6e..4bde637a0 100644 --- a/glamor/glamor_egl.c +++ b/glamor/glamor_egl.c @@ -769,6 +769,10 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd) glamor_egl->display = glamor_egl_get_display(EGL_PLATFORM_GBM_MESA, glamor_egl->gbm); + if (!glamor_egl->display) { + xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglGetDisplay() failed\n"); + goto error; + } #else glamor_egl->display = eglGetDisplay((EGLNativeDisplayType) (intptr_t) fd); #endif diff --git a/glamor/glamor_egl.h b/glamor/glamor_egl.h index 6b05f576f..2c6d3076f 100644 --- a/glamor/glamor_egl.h +++ b/glamor/glamor_egl.h @@ -67,9 +67,7 @@ glamor_egl_get_display(EGLint type, void *native) PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT = (void *) eglGetProcAddress("eglGetPlatformDisplayEXT"); if (getPlatformDisplayEXT) - dpy = getPlatformDisplayEXT(type, native, NULL); - if (dpy) - return dpy; + return getPlatformDisplayEXT(type, native, NULL); } /* Welp, everything is awful. */ |