DRM drivers can be opened by meta_launcher_open_restricted() even if they don't
implement modesetting. However, drmModeGetResources() will return NULL.
Check whether that happened in meta_gpu_kms_new() and return with an error
instead of crashing.
Fixes #223.
Applied-Upstream: https://gitlab.gnome.org/GNOME/mutter/commit/
62660bbd15
Bug-GNOME: https://gitlab.gnome.org/GNOME/mutter/issues/223
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/gnome-shell/+bug/
1767956
Gbp-Pq: Name gpu-kms-Don-t-crash-if-drmModeGetResources-returns-N.patch
*/
drm_resources = drmModeGetResources (kms_fd);
+ if (!drm_resources)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "No resources");
+ meta_launcher_close_restricted (launcher, kms_fd);
+ return NULL;
+ }
+
n_connectors = drm_resources->count_connectors;
drmModeFreeResources (drm_resources);