Mesa (master): egl/wayland: bail out when drmGetMagic fails

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Nov 28 16:15:58 UTC 2018


Module: Mesa
Branch: master
Commit: c59d3aa4b9bc58994e199052171a8119aaa8195c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c59d3aa4b9bc58994e199052171a8119aaa8195c

Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Fri Nov 23 12:55:38 2018 +0000

egl/wayland: bail out when drmGetMagic fails

Currently as the function fails, we pass uninitialized data to the
authentication function. Stop doing that and print an warning when
the function fails.

v2: Plug memory leak in error path (Eric)

Cc: mesa-stable at lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
Reviewed-by: Tapani Pälli <tapani.palli at intel.com> (v1)
Reviewed-by: Eric Engestrom <eric.engestrom at intel.com>

---

 src/egl/drivers/dri2/platform_wayland.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 8122c81128..b05f536316 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -1133,7 +1133,14 @@ drm_handle_device(void *data, struct wl_drm *drm, const char *device)
    if (drmGetNodeTypeFromFd(dri2_dpy->fd) == DRM_NODE_RENDER) {
       dri2_dpy->authenticated = true;
    } else {
-      drmGetMagic(dri2_dpy->fd, &magic);
+      if (drmGetMagic(dri2_dpy->fd, &magic)) {
+         close(dri2_dpy->fd);
+         dri2_dpy->fd = -1;
+         free(dri2_dpy->device_name);
+         dri2_dpy->device_name = NULL:
+         _eglLog(_EGL_WARNING, "wayland-egl: drmGetMagic failed");
+         return;
+      }
       wl_drm_authenticate(dri2_dpy->wl_drm, magic);
    }
 }




More information about the mesa-commit mailing list