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



commit 5cb6286436381e256075a3abfdf182631a0ca88a
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Mon Jul 1 11:56:08 2019 +0200

    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

 src/backends/native/meta-kms-impl-device.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c
index eb5e350ed..09114ea17 100644
--- a/src/backends/native/meta-kms-impl-device.c
+++ b/src/backends/native/meta-kms-impl-device.c
@@ -328,13 +328,20 @@ meta_kms_impl_device_new (MetaKmsDevice  *device,
       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->device = device;
   impl_device->impl = impl;
   impl_device->fd = fd;
 
-  drm_resources = drmModeGetResources (fd);
-
   init_crtcs (impl_device, drm_resources);
   init_connectors (impl_device, drm_resources);
   init_planes (impl_device);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]