[mutter/gnome-41] kms/connector: Fix updating the state when drmConnector is NULL
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gnome-41] kms/connector: Fix updating the state when drmConnector is NULL
- Date: Wed, 24 Nov 2021 14:07:17 +0000 (UTC)
commit a421a9e8cd2a801b9f30bce3ab317000010b410b
Author: Jonas Ådahl <jadahl gmail com>
Date: Thu Nov 18 17:15:57 2021 +0100
kms/connector: Fix updating the state when drmConnector is NULL
When a docking station is disconnected, a few previously existing DRM
connectors may now be gone. When this happens, getting them via the
libdrm API results in NULL pointers returning, and we need to handle
this gracefully by making sure the connector state is properly updated.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2097>
(cherry picked from commit 8546ca31ff91d5adcec6d5d028f8fcdeee239985)
src/backends/native/meta-kms-connector.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/src/backends/native/meta-kms-connector.c b/src/backends/native/meta-kms-connector.c
index 5121dc94d8..4f1b38da59 100644
--- a/src/backends/native/meta-kms-connector.c
+++ b/src/backends/native/meta-kms-connector.c
@@ -138,7 +138,9 @@ sync_fd_held (MetaKmsConnector *connector,
{
gboolean should_hold_fd;
- should_hold_fd = connector->current_state->current_crtc_id != 0;
+ should_hold_fd =
+ connector->current_state &&
+ connector->current_state->current_crtc_id != 0;
if (connector->fd_held == should_hold_fd)
return;
@@ -569,6 +571,13 @@ meta_kms_connector_read_state (MetaKmsConnector *connector,
current_state = g_steal_pointer (&connector->current_state);
changes = META_KMS_UPDATE_CHANGE_NONE;
+ if (!drm_connector)
+ {
+ if (current_state)
+ changes = META_KMS_UPDATE_CHANGE_FULL;
+ goto out;
+ }
+
if (drm_connector->connection != DRM_MODE_CONNECTED)
{
if (drm_connector->connection != connector->connection)
@@ -577,7 +586,7 @@ meta_kms_connector_read_state (MetaKmsConnector *connector,
changes |= META_KMS_UPDATE_CHANGE_FULL;
}
- return changes;
+ goto out;
}
state = meta_kms_connector_state_new ();
@@ -616,8 +625,8 @@ meta_kms_connector_read_state (MetaKmsConnector *connector,
changes |= connector_changes;
}
- if (changes != META_KMS_UPDATE_CHANGE_NONE)
- sync_fd_held (connector, impl_device);
+out:
+ sync_fd_held (connector, impl_device);
return changes;
}
@@ -634,13 +643,10 @@ meta_kms_connector_update_state (MetaKmsConnector *connector,
drm_connector = drmModeGetConnector (meta_kms_impl_device_get_fd (impl_device),
connector->id);
- if (!drm_connector)
- return META_KMS_UPDATE_CHANGE_FULL;
-
changes = meta_kms_connector_read_state (connector, impl_device,
drm_connector,
drm_resources);
- drmModeFreeConnector (drm_connector);
+ g_clear_pointer (&drm_connector, drmModeFreeConnector);
return changes;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]