From: Derek Foreman Date: Wed, 17 Jun 2015 16:28:48 +0000 (-0500) Subject: egl/drm: Duplicate fd with F_DUPFD_CLOEXEC to prevent leak X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aaac913e901229d11a1894f6aaf646de6b1a542c;p=mesa.git 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 Reviewed-by: Kristian Høgsberg Reviewed-by: Emil Velikov --- 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;