kms-impl-device: Clean up state if drm resources disappear

It may happen that drmModeGetResources() starts returning NULL. Handle
this gracefully by removing all connectors, CRTCs and planes making the
device in practice defunct.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1121


(cherry picked from commit 5319949a45)
This commit is contained in:
Jonas Ådahl
2020-03-11 10:46:48 +00:00
parent a5b5e95ad9
commit 7655a63af6

View File

@ -326,6 +326,16 @@ meta_kms_impl_device_update_states (MetaKmsImplDevice *impl_device)
meta_assert_in_kms_impl (meta_kms_impl_get_kms (impl_device->impl));
drm_resources = drmModeGetResources (impl_device->fd);
if (!drm_resources)
{
g_list_free_full (impl_device->planes, g_object_unref);
g_list_free_full (impl_device->crtcs, g_object_unref);
g_list_free_full (impl_device->connectors, g_object_unref);
impl_device->planes = NULL;
impl_device->crtcs = NULL;
impl_device->connectors = NULL;
return;
}
update_connectors (impl_device, drm_resources);