egl/platform/drm: Don't take display ownership until gbm is initialized
authorAdam Jackson <ajax@redhat.com>
Wed, 3 May 2017 15:03:34 +0000 (11:03 -0400)
committerAdam Jackson <ajax@redhat.com>
Thu, 4 May 2017 16:52:18 +0000 (12:52 -0400)
If the gbm_create_device() call here actually did fail, any subsequent
eglTerminate on the display would segfault.

Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
src/egl/drivers/dri2/platform_drm.c

index cf35ce8a1f2eb813ff8e31f87bbca3a26044a72e..9431d95e0a7bb1489cf06a2e1aca16ceaa4aa274 100644 (file)
@@ -689,12 +689,12 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
          fd = loader_open_device(buf);
       if (fd < 0)
          fd = loader_open_device("/dev/dri/card0");
-      dri2_dpy->own_device = 1;
       gbm = gbm_create_device(fd);
       if (gbm == NULL) {
          err = "DRI2: failed to create gbm device";
          goto cleanup;
       }
+      dri2_dpy->own_device = 1;
    } else {
       fd = fcntl(gbm_device_get_fd(gbm), F_DUPFD_CLOEXEC, 3);
       if (fd < 0) {