[Mesa-dev] [PATCH Mesa] egl/wayland: check drmGetMagic for failure

Eric Engestrom eric at engestrom.ch
Sun Jul 10 22:26:33 UTC 2016


Coverity (CovID 1255672) noticed that all the other calls to drmGetMagic were
checked for failure, but not this one. Fix this, and return before an invalid
magic token is used to authenticate the device.

Signed-off-by: Eric Engestrom <eric at engestrom.ch>
---
 src/egl/drivers/dri2/platform_wayland.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index e714e44..9de75f2 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -918,7 +918,10 @@ drm_handle_device(void *data, struct wl_drm *drm, const char *device)
    if (drmGetNodeTypeFromFd(dri2_dpy->fd) == DRM_NODE_RENDER) {
       dri2_dpy->authenticated = 1;
    } else {
-      drmGetMagic(dri2_dpy->fd, &magic);
+      if (drmGetMagic(dri2_dpy->fd, &magic)) {
+         _eglLog(_EGL_WARNING, "wayland-egl: failed to get drm magic");
+         return;
+      }
       wl_drm_authenticate(dri2_dpy->wl_drm, magic);
    }
 }
-- 
2.9.0



More information about the mesa-dev mailing list