Skip to contentSkip to conversation

Always pass O_CLOEXEC when opening DRM file descriptors

PATCH In review Michel Dänzer 2 participants 2 messages May 18, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Always pass O_CLOEXEC when opening DRM file descriptors

From: Michel Dänzer <[email protected]>

---
 xf86drm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
xf86drm.c +3 -3
index 3a9d0ed2..c09437b0 100644
@@ -405,7 +405,7 @@ wait_for_udev:
     }
 #endif
 
-    fd = open(buf, O_RDWR, 0);
+    fd = open(buf, O_RDWR | O_CLOEXEC, 0);
     drmMsg("drmOpenDevice: open result is %d, (%s)\n",
            fd, fd < 0 ? strerror(errno) : "OK");
     if (fd >= 0)
@@ -425,7 +425,7 @@ wait_for_udev:
             chmod(buf, devmode);
         }
     }
-    fd = open(buf, O_RDWR, 0);
+    fd = open(buf, O_RDWR | O_CLOEXEC, 0);
     drmMsg("drmOpenDevice: open result is %d, (%s)\n",
            fd, fd < 0 ? strerror(errno) : "OK");
     if (fd >= 0)
@@ -474,7 +474,7 @@ static int drmOpenMinor(int minor, int create, int type)
     };
 
     sprintf(buf, dev_name, DRM_DIR_NAME, minor);
-    if ((fd = open(buf, O_RDWR, 0)) >= 0)
+    if ((fd = open(buf, O_RDWR | O_CLOEXEC, 0)) >= 0)
         return fd;
     return -errno;
 }
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw

Am 18.05.2018 um 11:17 schrieb Michel Dänzer:

Quoted 3 lines

From: Michel Dänzer <[email protected]>

Quoted 27 lines
---
  xf86drm.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
xf86drm.c +2 -2
index 3a9d0ed2..c09437b0 100644
@@ -405,7 +405,7 @@ wait_for_udev:
      }
  #endif
 
-    fd = open(buf, O_RDWR, 0);
+    fd = open(buf, O_RDWR | O_CLOEXEC, 0);
      drmMsg("drmOpenDevice: open result is %d, (%s)\n",
             fd, fd < 0 ? strerror(errno) : "OK");
      if (fd >= 0)
@@ -425,7 +425,7 @@ wait_for_udev:
              chmod(buf, devmode);
          }
      }
-    fd = open(buf, O_RDWR, 0);
+    fd = open(buf, O_RDWR | O_CLOEXEC, 0);
      drmMsg("drmOpenDevice: open result is %d, (%s)\n",
             fd, fd < 0 ? strerror(errno) : "OK");
      if (fd >= 0)

xf86drm.c static int drmOpenMinor(int minor, int create, int type) · line 480

Quoted 8 lines
xf86drm.c +1 -1
@@ -474,7 +474,7 @@ static int drmOpenMinor(int minor, int create, int type)
      };
 
      sprintf(buf, dev_name, DRM_DIR_NAME, minor);
-    if ((fd = open(buf, O_RDWR, 0)) >= 0)
+    if ((fd = open(buf, O_RDWR | O_CLOEXEC, 0)) >= 0)
          return fd;
      return -errno;
  }

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel