diff options
author | Hans de Goede <hdegoede@redhat.com> | 2019-08-02 22:57:28 +0200 |
---|---|---|
committer | Jonas Ã…dahl <jadahl@gmail.com> | 2019-08-15 20:38:28 +0000 |
commit | 578ff2246411e9dbd4f14cbc34e03ebe173de8d0 (patch) | |
tree | 8cc03d6bef6db234d45a9e1bbb1893b10f52f982 /src/backends/native/meta-kms-crtc.c | |
parent | 73db35c53c71759b3ea4e864db64d1fb57094a1c (diff) | |
download | mutter-578ff2246411e9dbd4f14cbc34e03ebe173de8d0.tar.gz |
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
Diffstat (limited to 'src/backends/native/meta-kms-crtc.c')
-rw-r--r-- | src/backends/native/meta-kms-crtc.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/backends/native/meta-kms-crtc.c b/src/backends/native/meta-kms-crtc.c index b07a6e7d5..2b0f5385a 100644 --- a/src/backends/native/meta-kms-crtc.c +++ b/src/backends/native/meta-kms-crtc.c @@ -132,6 +132,13 @@ meta_kms_crtc_update_state (MetaKmsCrtc *crtc) impl_device = meta_kms_device_get_impl_device (crtc->device); drm_crtc = drmModeGetCrtc (meta_kms_impl_device_get_fd (impl_device), 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); drmModeFreeCrtc (drm_crtc); } |