struct drm_display_mode *mode = NULL;
        struct qxl_head *head;
 
+       if (!qdev->monitors_config)
+               return 0;
+       if (h >= qdev->monitors_config->max_allowed)
+               return 0;
        if (!qdev->client_monitors_config)
                return 0;
+       if (h >= qdev->client_monitors_config->count)
+               return 0;
+
        head = &qdev->client_monitors_config->heads[h];
+       DRM_DEBUG_KMS("head %d is %dx%d\n", h, head->width, head->height);
 
        mode = drm_cvt_mode(dev, head->width, head->height, 60, false, false,
                            false);
 
 static int qxl_conn_get_modes(struct drm_connector *connector)
 {
-       int ret = 0;
-       struct qxl_device *qdev = connector->dev->dev_private;
        unsigned pwidth = 1024;
        unsigned pheight = 768;
+       int ret = 0;
 
-       DRM_DEBUG_KMS("monitors_config=%p\n", qdev->monitors_config);
-       /* TODO: what should we do here? only show the configured modes for the
-        * device, or allow the full list, or both? */
-       if (qdev->monitors_config && qdev->monitors_config->count) {
-               ret = qxl_add_monitors_config_modes(connector, &pwidth, &pheight);
-               if (ret < 0)
-                       return ret;
-       }
+       ret = qxl_add_monitors_config_modes(connector, &pwidth, &pheight);
+       if (ret < 0)
+               return ret;
        ret += qxl_add_common_modes(connector, pwidth, pheight);
        return ret;
 }