summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/dri
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/dri')
-rw-r--r--src/gallium/state_trackers/dri/dri2.c19
-rw-r--r--src/gallium/state_trackers/dri/dri_screen.c1
2 files changed, 3 insertions, 17 deletions
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 20540e39881..b17c5e16ede 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -29,7 +29,6 @@
*/
#include <xf86drm.h>
-#include <fcntl.h>
#include "GL/mesa_glinterop.h"
#include "util/u_memory.h"
#include "util/u_inlines.h"
@@ -2103,7 +2102,6 @@ dri2_init_screen(__DRIscreen * sPriv)
struct pipe_screen *pscreen = NULL;
const struct drm_conf_ret *throttle_ret;
const struct drm_conf_ret *dmabuf_ret;
- int fd;
screen = CALLOC_STRUCT(dri_screen);
if (!screen)
@@ -2115,11 +2113,7 @@ dri2_init_screen(__DRIscreen * sPriv)
sPriv->driverPrivate = (void *)screen;
- if (screen->fd < 0 || (fd = fcntl(screen->fd, F_DUPFD_CLOEXEC, 3)) < 0)
- goto free_screen;
-
-
- if (pipe_loader_drm_probe_fd(&screen->dev, fd)) {
+ if (pipe_loader_drm_probe_fd(&screen->dev, screen->fd)) {
dri_init_options(screen);
pscreen = pipe_loader_create_screen(screen->dev);
@@ -2180,10 +2174,7 @@ destroy_screen:
release_pipe:
if (screen->dev)
pipe_loader_release(&screen->dev, 1);
- else
- close(fd);
-free_screen:
FREE(screen);
return NULL;
}
@@ -2212,10 +2203,7 @@ dri_kms_init_screen(__DRIscreen * sPriv)
sPriv->driverPrivate = (void *)screen;
- if (screen->fd < 0 || (fd = fcntl(screen->fd, F_DUPFD_CLOEXEC, 3)) < 0)
- goto free_screen;
-
- if (pipe_loader_sw_probe_kms(&screen->dev, fd)) {
+ if (pipe_loader_sw_probe_kms(&screen->dev, screen->fd)) {
dri_init_options(screen);
pscreen = pipe_loader_create_screen(screen->dev);
}
@@ -2257,10 +2245,7 @@ destroy_screen:
release_pipe:
if (screen->dev)
pipe_loader_release(&screen->dev, 1);
- else
- close(fd);
-free_screen:
FREE(screen);
#endif // GALLIUM_SOFTPIPE
return NULL;
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index 308e23685e8..82a0988a634 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -488,6 +488,7 @@ dri_destroy_screen(__DRIscreen * sPriv)
pipe_loader_release(&screen->dev, 1);
+ /* The caller in dri_util preserves the fd ownership */
free(screen);
sPriv->driverPrivate = NULL;
sPriv->extensions = NULL;