[Mesa-dev] [PATCH 4/5] st/xa: replace call to dup(2) with fcntl(F_DUPFD_CLOEXEC)

Matt Whitlock freedesktop at mattwhitlock.name
Sun Oct 2 03:49:44 UTC 2016


Without this fix, duplicated file descriptors leak into child processes.
See commit aaac913e901229d11a1894f6aaf646de6b1a542c for one instance
where the same fix was employed.

Cc: <mesa-stable at lists.freedesktop.org>
Signed-off-by: Matt Whitlock <freedesktop at mattwhitlock.name>
---
 src/gallium/state_trackers/xa/xa_tracker.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
index d98bd2d..03a3abf 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -27,6 +27,7 @@
  */
 
 #include <unistd.h>
+#include <fcntl.h>
 #include "xa_tracker.h"
 #include "xa_priv.h"
 #include "pipe/p_state.h"
@@ -157,7 +158,7 @@ xa_tracker_create(int drm_fd)
     if (!xa)
 	return NULL;
 
-    if (drm_fd < 0 || (fd = dup(drm_fd)) < 0)
+    if (drm_fd < 0 || (fd = fcntl(drm_fd, F_DUPFD_CLOEXEC, 3)) < 0)
 	goto out_no_fd;
 
     if (pipe_loader_drm_probe_fd(&xa->dev, fd))
-- 
2.10.0



More information about the mesa-dev mailing list