diff options
author | Simon Ser <contact@emersion.fr> | 2021-04-29 09:12:45 +0200 |
---|---|---|
committer | Kenny Levinsen <kl@kl.wtf> | 2021-04-29 19:59:42 +0200 |
commit | c85789a3a9f6f851e6fbc900495057ba91b3e255 (patch) | |
tree | 36cf530668c95738d913e9d346927ab2d32e9d97 /backend/headless | |
parent | a1e8a639b3626b474d49e7694bd0c9e3945adf0c (diff) |
backend/headless: dup DRM FD in wlr_headless_backend_create_with_renderer
We were not dup'ing the DRM FD coming from wlr_renderer_get_drm_fd,
resulting in a double-close on backend destroy.
Diffstat (limited to 'backend/headless')
-rw-r--r-- | backend/headless/backend.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/backend/headless/backend.c b/backend/headless/backend.c index be44a980..2617b812 100644 --- a/backend/headless/backend.c +++ b/backend/headless/backend.c @@ -248,9 +248,15 @@ struct wlr_backend *wlr_headless_backend_create_with_renderer( } backend->has_parent_renderer = true; - backend->drm_fd = wlr_renderer_get_drm_fd(renderer); - if (backend->drm_fd < 0) { - wlr_log(WLR_ERROR, "Failed to get DRM device FD from renderer"); + int drm_fd = wlr_renderer_get_drm_fd(renderer); + if (drm_fd < 0) { + wlr_log(WLR_ERROR, "Failed to get DRM device FD from parent renderer"); + backend->drm_fd = -1; + } else { + backend->drm_fd = fcntl(drm_fd, F_DUPFD_CLOEXEC, 0); + if (backend->drm_fd < 0) { + wlr_log_errno(WLR_ERROR, "fcntl(F_DUPFD_CLOEXEC) failed"); + } } if (!backend_init(backend, display, renderer)) { |