kms-impl-device: Fail up front if we can't retrieve DRM resources

If we can't retrieve the drm resources, instead of segfaulting later on,
treat it as an error, and let the error handler up the stack handle it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/665
This commit is contained in:
Jonas Ådahl 2019-07-01 11:56:08 +02:00
parent 1c25b75571
commit 5cb6286436

View File

@ -328,13 +328,20 @@ meta_kms_impl_device_new (MetaKmsDevice *device,
return NULL; return NULL;
} }
drm_resources = drmModeGetResources (fd);
if (!drm_resources)
{
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
"Failed to activate universal planes: %s",
g_strerror (errno));
return NULL;
}
impl_device = g_object_new (META_TYPE_KMS_IMPL_DEVICE, NULL); impl_device = g_object_new (META_TYPE_KMS_IMPL_DEVICE, NULL);
impl_device->device = device; impl_device->device = device;
impl_device->impl = impl; impl_device->impl = impl;
impl_device->fd = fd; impl_device->fd = fd;
drm_resources = drmModeGetResources (fd);
init_crtcs (impl_device, drm_resources); init_crtcs (impl_device, drm_resources);
init_connectors (impl_device, drm_resources); init_connectors (impl_device, drm_resources);
init_planes (impl_device); init_planes (impl_device);