Pass O_CLOEXEC to drmModeCreateLease calls

The lease_fd is currently being leaked to child processes

Link: https://github.com/swaywm/sway/issues/4286#issuecomment-1065987957
This commit is contained in:
Samuel Čavoj 2022-03-13 12:28:55 +01:00
parent 4c8ecfcd4a
commit 5c17452ae0
No known key found for this signature in database
GPG key ID: 5DFA998B099F923F
2 changed files with 2 additions and 2 deletions

View file

@ -1629,7 +1629,7 @@ struct wlr_drm_lease *wlr_drm_create_lease(struct wlr_output **outputs,
wl_signal_init(&lease->events.destroy);
wlr_log(WLR_DEBUG, "Issuing DRM lease with %d objects", n_objects);
int lease_fd = drmModeCreateLease(drm->fd, objects, n_objects, 0,
int lease_fd = drmModeCreateLease(drm->fd, objects, n_objects, O_CLOEXEC,
&lease->lessee_id);
if (lease_fd < 0) {
free(lease);

View file

@ -30,7 +30,7 @@ static int reopen_drm_node(int drm_fd, bool allow_render_node) {
if (drmIsMaster(drm_fd)) {
// Only recent kernels support empty leases
uint32_t lessee_id;
int lease_fd = drmModeCreateLease(drm_fd, NULL, 0, 0, &lessee_id);
int lease_fd = drmModeCreateLease(drm_fd, NULL, 0, O_CLOEXEC, &lessee_id);
if (lease_fd >= 0) {
return lease_fd;
} else if (lease_fd != -EINVAL && lease_fd != -EOPNOTSUPP) {