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
This commit is contained in:
Hans de Goede 2019-08-02 22:48:41 +02:00 committed by Jonas Ådahl
parent 578ff22464
commit 3ccb7cf4b2
2 changed files with 4 additions and 1 deletions

View File

@ -456,7 +456,7 @@ meta_kms_connector_read_state (MetaKmsConnector *connector,
g_clear_pointer (&connector->current_state, meta_kms_connector_state_free); 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; return;
state = meta_kms_connector_state_new (); state = meta_kms_connector_state_new ();

View File

@ -209,6 +209,9 @@ init_connectors (MetaKmsImplDevice *impl_device,
drm_connector = drmModeGetConnector (impl_device->fd, drm_connector = drmModeGetConnector (impl_device->fd,
drm_resources->connectors[i]); drm_resources->connectors[i]);
if (!drm_connector)
continue;
connector = meta_kms_connector_new (impl_device, drm_connector, connector = meta_kms_connector_new (impl_device, drm_connector,
drm_resources); drm_resources);
drmModeFreeConnector (drm_connector); drmModeFreeConnector (drm_connector);