kms: drmModeGetCrtc may fail

drmModeGetCrtc may fail and return NULL. This will trigger when
meta_kms_crtc_update_state gets called from meta_kms_update_states_sync
after a GPU has been unplugged leading to a NULL pointer deref causing
a crash.

This commit fixes this by checking for NULL and clearing the current_state
when NULL is returned.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
This commit is contained in:
Hans de Goede 2019-08-02 22:57:28 +02:00 committed by Jonas Ådahl
parent 73db35c53c
commit 578ff22464

View File

@ -132,6 +132,13 @@ meta_kms_crtc_update_state (MetaKmsCrtc *crtc)
impl_device = meta_kms_device_get_impl_device (crtc->device); impl_device = meta_kms_device_get_impl_device (crtc->device);
drm_crtc = drmModeGetCrtc (meta_kms_impl_device_get_fd (impl_device), drm_crtc = drmModeGetCrtc (meta_kms_impl_device_get_fd (impl_device),
crtc->id); crtc->id);
if (!drm_crtc)
{
crtc->current_state.rect = (MetaRectangle) { };
crtc->current_state.is_drm_mode_valid = FALSE;
return;
}
meta_kms_crtc_read_state (crtc, impl_device, drm_crtc); meta_kms_crtc_read_state (crtc, impl_device, drm_crtc);
drmModeFreeCrtc (drm_crtc); drmModeFreeCrtc (drm_crtc);
} }