overlay: Close DRI2 device after authentication failure
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 22 Aug 2013 19:42:58 +0000 (20:42 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 22 Aug 2013 21:15:46 +0000 (22:15 +0100)
So that we don't leave a master fd open when operating remotely.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
overlay/x11/dri2.c

index 0aa0cf5..6c9e90d 100644 (file)
@@ -39,6 +39,7 @@
 #include <xf86drm.h>
 #include <drm.h>
 #include <fcntl.h>
+#include <unistd.h>
 
 #include "dri2.h"
 
@@ -160,10 +161,14 @@ int dri2_open(Display *dpy)
                return -1;
 
        if (drmIoctl(fd, DRM_IOCTL_GET_MAGIC, &auth))
-               return -1;
+               goto err_fd;
 
        if (!DRI2Authenticate(dpy, DefaultRootWindow(dpy), auth.magic))
-               return -1;
+               goto err_fd;
 
        return fd;
+
+err_fd:
+       close(fd);
+       return -1;
 }