st/dri: Don't close the drm fd on failure
authorEmil Velikov <emil.l.velikov@gmail.com>
Wed, 14 Oct 2015 23:45:13 +0000 (00:45 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Sat, 21 Nov 2015 12:52:20 +0000 (12:52 +0000)
Ported from an identically named commit in st/xa

commit 35cf3831d71770211f29da6608313dc1f6213d7b
Author: Thomas Hellstrom <thellstrom@vmware.com>
Date:   Thu Jul 3 02:07:36 2014 -0700

    st/xa: Don't close the drm fd on failure v2

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Rob Clark <robclark@freedesktop.org>
src/gallium/state_trackers/dri/dri2.c

index 62173750381d4515d8fc38cd27efb08ca425040e..5b7be64ba5a0bc1b5a4e24f4c69ba87845a9b308 100644 (file)
@@ -1457,7 +1457,7 @@ dri2_init_screen(__DRIscreen * sPriv)
 
    sPriv->driverPrivate = (void *)screen;
 
-   if (pipe_loader_drm_probe_fd(&screen->dev, screen->fd)) {
+   if (pipe_loader_drm_probe_fd(&screen->dev, dup(screen->fd))) {
       pscreen = pipe_loader_create_screen(screen->dev);
 
       throttle_ret = pipe_loader_configuration(screen->dev, DRM_CONF_THROTTLE);
@@ -1529,7 +1529,7 @@ dri_kms_init_screen(__DRIscreen * sPriv)
 
    sPriv->driverPrivate = (void *)screen;
 
-   if (pipe_loader_sw_probe_kms(&screen->dev, screen->fd))
+   if (pipe_loader_sw_probe_kms(&screen->dev, dup(screen->fd)))
       pscreen = pipe_loader_create_screen(screen->dev);
 
    if (drmGetCap(sPriv->fd, DRM_CAP_PRIME, &cap) == 0 &&