aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-03-29 16:14:38 +0200
committerSimon Zeni <simon@bl4ckb0ne.ca>2022-05-02 15:44:16 +0000
commit410c08cdc676de1f24d71d8817587e1f7e6b4093 (patch)
tree7c8c070830a14d050530d93e6281fdc08e1ed44d
parent95d3529edf16add98d0f2f7c749b59d2d861bfa4 (diff)
drm-lease-v1: skip device on wlr_drm_backend_get_non_master_fd failure
On some setups, wlr_drm_backend_get_non_master_fd may fail because of permission issues. Instead of exposing a bogus global, bail out. Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3391
-rw-r--r--types/wlr_drm_lease_v1.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/types/wlr_drm_lease_v1.c b/types/wlr_drm_lease_v1.c
index 7cb9974d..0ef9e036 100644
--- a/types/wlr_drm_lease_v1.c
+++ b/types/wlr_drm_lease_v1.c
@@ -621,10 +621,18 @@ static void handle_backend_destroy(struct wl_listener *listener, void *data) {
static void drm_lease_device_v1_create(struct wlr_drm_lease_v1_manager *manager,
struct wlr_backend *backend) {
- assert(backend);
+ struct wlr_drm_backend *drm_backend = get_drm_backend_from_backend(backend);
+
+ // Make sure we can get a non-master FD for the DRM backend. On some setups
+ // we don't have the permission for this.
+ int fd = wlr_drm_backend_get_non_master_fd(backend);
+ if (fd < 0) {
+ wlr_log(WLR_INFO, "Skipping %s: failed to get read-only DRM FD",
+ drm_backend->name);
+ return;
+ }
+ close(fd);
- struct wlr_drm_backend *drm_backend =
- get_drm_backend_from_backend(backend);
wlr_log(WLR_DEBUG, "Creating wlr_drm_lease_device_v1 for %s",
drm_backend->name);