summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Matos <tiagomatos@gmail.com>2015-04-28 16:52:20 +0200
committerRui Matos <tiagomatos@gmail.com>2015-04-28 18:00:45 +0200
commit7eca43cec93b37a3db3a2d66aff86569e0f60313 (patch)
tree6259f82f8972b2cd08ddfe6693665500ee34b7fb
parent9060190555dcf1aa84715bab496cdfe4f6d79f1b (diff)
monitor-manager-kms: Avoid a couple of potential crashes
The drm API can return NULL and we could end up using uninitialized memory if the driver private struct isn't cleared.
-rw-r--r--src/backends/native/meta-monitor-manager-kms.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backends/native/meta-monitor-manager-kms.c b/src/backends/native/meta-monitor-manager-kms.c
index 3e1cef3a..f0d93809 100644
--- a/src/backends/native/meta-monitor-manager-kms.c
+++ b/src/backends/native/meta-monitor-manager-kms.c
@@ -224,6 +224,9 @@ find_crtc_properties (MetaMonitorManagerKms *manager_kms,
crtc_kms = meta_crtc->driver_private;
props = drmModeObjectGetProperties (manager_kms->fd, meta_crtc->crtc_id, DRM_MODE_OBJECT_CRTC);
+ if (!props)
+ return;
+
for (i = 0; i < props->count_props; i++)
{
drmModePropertyPtr prop = drmModeGetProperty (manager_kms->fd, props->props[i]);
@@ -479,7 +482,7 @@ meta_monitor_manager_kms_read_current (MetaMonitorManager *manager)
height = MAX (height, meta_crtc->rect.y + meta_crtc->rect.height);
}
- meta_crtc->driver_private = g_new (MetaCRTCKms, 1);
+ meta_crtc->driver_private = g_new0 (MetaCRTCKms, 1);
meta_crtc->driver_notify = (GDestroyNotify) meta_crtc_destroy_notify;
find_crtc_properties (manager_kms, meta_crtc);