kms-device: Handle impl device creation failure

Properly free kms-device in case of invalid initialization

https://gitlab.gnome.org/GNOME/mutter/merge_requests/772
This commit is contained in:
Michal Lazo 2019-09-16 16:34:39 +00:00 committed by Jonas Ådahl
parent 6922f0e16a
commit d13cea6ccb

View File

@ -211,6 +211,7 @@ meta_kms_device_new (MetaKms *kms,
return NULL; return NULL;
device = g_object_new (META_TYPE_KMS_DEVICE, NULL); device = g_object_new (META_TYPE_KMS_DEVICE, NULL);
device->kms = kms;
data = (CreateImplDeviceData) { data = (CreateImplDeviceData) {
.device = device, .device = device,
@ -224,7 +225,6 @@ meta_kms_device_new (MetaKms *kms,
return NULL; return NULL;
} }
device->kms = kms;
device->impl_device = data.out_impl_device; device->impl_device = data.out_impl_device;
device->flags = flags; device->flags = flags;
device->path = g_strdup (path); device->path = g_strdup (path);
@ -266,13 +266,16 @@ meta_kms_device_finalize (GObject *object)
MetaBackend *backend = meta_kms_get_backend (device->kms); MetaBackend *backend = meta_kms_get_backend (device->kms);
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend); MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
MetaLauncher *launcher = meta_backend_native_get_launcher (backend_native); MetaLauncher *launcher = meta_backend_native_get_launcher (backend_native);
FreeImplDeviceData data;
GError *error = NULL;
g_list_free (device->crtcs); g_list_free (device->crtcs);
g_list_free (device->connectors); g_list_free (device->connectors);
g_list_free (device->planes); g_list_free (device->planes);
if (device->impl_device)
{
FreeImplDeviceData data;
GError *error = NULL;
data = (FreeImplDeviceData) { data = (FreeImplDeviceData) {
.impl_device = device->impl_device, .impl_device = device->impl_device,
}; };
@ -286,7 +289,7 @@ meta_kms_device_finalize (GObject *object)
{ {
meta_launcher_close_restricted (launcher, data.out_fd); meta_launcher_close_restricted (launcher, data.out_fd);
} }
}
G_OBJECT_CLASS (meta_kms_device_parent_class)->finalize (object); G_OBJECT_CLASS (meta_kms_device_parent_class)->finalize (object);
} }