Mesa (master): egl/drm: Duplicate fd with F_DUPFD_CLOEXEC to prevent leak

Emil Velikov evelikov at kemper.freedesktop.org
Tue Jun 23 16:07:38 UTC 2015


Module: Mesa
Branch: master
Commit: aaac913e901229d11a1894f6aaf646de6b1a542c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=aaac913e901229d11a1894f6aaf646de6b1a542c

Author: Derek Foreman <derekf at osg.samsung.com>
Date:   Wed Jun 17 11:28:48 2015 -0500

egl/drm: Duplicate fd with F_DUPFD_CLOEXEC to prevent leak

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 <derekf at osg.samsung.com>
Reviewed-by: Kristian Høgsberg <krh at bitplanet.net>
Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>

---

 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 3391afc..c97c54f 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;




More information about the mesa-commit mailing list