From 3ccb7cf4b23c9d25a9ced4b6981e9018e52f75a9 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 2 Aug 2019 22:48:41 +0200 Subject: [PATCH] kms: drmModeGetConnector may fail drmModeGetConnector may fail and return NULL, this may happen when a connector is removed underneath us (which can happen with e.g. DP MST or GPU hot unplug). Deal with this by skipping the connector when enumerating and by assuming it is disconnected when checking its connection state. https://gitlab.gnome.org/GNOME/mutter/merge_requests/713 --- src/backends/native/meta-kms-connector.c | 2 +- src/backends/native/meta-kms-impl-device.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backends/native/meta-kms-connector.c b/src/backends/native/meta-kms-connector.c index 70d3336d3..226dd5e71 100644 --- a/src/backends/native/meta-kms-connector.c +++ b/src/backends/native/meta-kms-connector.c @@ -456,7 +456,7 @@ meta_kms_connector_read_state (MetaKmsConnector *connector, g_clear_pointer (&connector->current_state, meta_kms_connector_state_free); - if (drm_connector->connection != DRM_MODE_CONNECTED) + if (!drm_connector || drm_connector->connection != DRM_MODE_CONNECTED) return; state = meta_kms_connector_state_new (); diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c index 09114ea17..c46d74646 100644 --- a/src/backends/native/meta-kms-impl-device.c +++ b/src/backends/native/meta-kms-impl-device.c @@ -209,6 +209,9 @@ init_connectors (MetaKmsImplDevice *impl_device, drm_connector = drmModeGetConnector (impl_device->fd, drm_resources->connectors[i]); + if (!drm_connector) + continue; + connector = meta_kms_connector_new (impl_device, drm_connector, drm_resources); drmModeFreeConnector (drm_connector);