[PATCH xserver 2/2] modesetting: Pass O_CLOEXEC when opening a DRM device

Michel Dänzer michel at daenzer.net
Fri May 18 09:23:01 UTC 2018


From: Michel Dänzer <michel.daenzer at amd.com>

We don't want DRM file descriptors to leak to child processes.

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 hw/xfree86/drivers/modesetting/driver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index 5d8906d63..306541f33 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -200,12 +200,12 @@ open_hw(const char *dev)
     int fd;
 
     if (dev)
-        fd = open(dev, O_RDWR, 0);
+        fd = open(dev, O_RDWR | O_CLOEXEC, 0);
     else {
         dev = getenv("KMSDEVICE");
-        if ((NULL == dev) || ((fd = open(dev, O_RDWR, 0)) == -1)) {
+        if ((NULL == dev) || ((fd = open(dev, O_RDWR | O_CLOEXEC, 0)) == -1)) {
             dev = "/dev/dri/card0";
-            fd = open(dev, O_RDWR, 0);
+            fd = open(dev, O_RDWR | O_CLOEXEC, 0);
         }
     }
     if (fd == -1)
-- 
2.17.0



More information about the xorg-devel mailing list