From aaac913e901229d11a1894f6aaf646de6b1a542c Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Wed, 17 Jun 2015 11:28:48 -0500 Subject: [PATCH] egl/drm: Duplicate fd with F_DUPFD_CLOEXEC to prevent leak MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Replacing dup() with fcntl F_DUPFD_CLOEXEC creates the duplicate file descriptor with CLOEXEC so it won't be leaked to child processes if the process fork()s later. Signed-off-by: Derek Foreman Reviewed-by: Kristian Høgsberg Reviewed-by: Emil Velikov --- src/egl/drivers/dri2/platform_drm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index 3391afc635c..c97c54fb58b 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -632,7 +632,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) } if (fd < 0) { - fd = dup(gbm_device_get_fd(gbm)); + fd = fcntl(gbm_device_get_fd(gbm), F_DUPFD_CLOEXEC, 3); if (fd < 0) { free(dri2_dpy); return EGL_FALSE; -- 2.30.2