auxiliary/vl/dri: fd management cleanups
authorEmil Velikov <emil.l.velikov@gmail.com>
Mon, 23 Nov 2015 20:26:59 +0000 (20:26 +0000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Sun, 29 Nov 2015 14:41:00 +0000 (14:41 +0000)
Analogous to previous commit, minus the extra dup. We are the one
opening the device thus we can directly use the fd.

Spotted by Coverity (CID 13398671339877)

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
src/gallium/auxiliary/vl/vl_winsys_dri.c

index ae0d4cdee1bf9145abe56b7ec7babb6338d99c16..758f50d7c23e32d24bbca29b686b85ed7dfa6529 100644 (file)
@@ -392,7 +392,7 @@ vl_dri2_screen_create(Display *display, int screen)
       goto free_connect;
 
    if (drmGetMagic(fd, &magic))
-      goto free_connect;
+      goto close_fd;
 
    authenticate_cookie = xcb_dri2_authenticate_unchecked(scrn->conn,
                                                          get_xcb_screen(s, screen)->root,
@@ -402,7 +402,7 @@ vl_dri2_screen_create(Display *display, int screen)
    if (authenticate == NULL || !authenticate->authenticated)
       goto free_authenticate;
 
-   if (pipe_loader_drm_probe_fd(&scrn->base.dev, dup(fd)))
+   if (pipe_loader_drm_probe_fd(&scrn->base.dev, fd))
       scrn->base.pscreen = pipe_loader_create_screen(scrn->base.dev);
 
    if (!scrn->base.pscreen)
@@ -428,8 +428,11 @@ vl_dri2_screen_create(Display *display, int screen)
 release_pipe:
    if (scrn->base.dev)
       pipe_loader_release(&scrn->base.dev, 1);
+   fd = -1;
 free_authenticate:
    free(authenticate);
+close_fd:
+   close(fd);
 free_connect:
    free(connect);
 free_query: