From 5319949a45bb22f5c998b485e955c1ddd13810f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 11 Mar 2020 11:46:48 +0100 Subject: [PATCH] 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 --- src/backends/native/meta-kms-impl-device.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c index e4f10d66e..80d7a8b01 100644 --- a/src/backends/native/meta-kms-impl-device.c +++ b/src/backends/native/meta-kms-impl-device.c @@ -365,6 +365,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);