From 776008da69fad8b776c93b42b19426c7ae43f326 Mon Sep 17 00:00:00 2001 From: emersion Date: Sun, 7 Oct 2018 12:59:00 +0200 Subject: backend/drm: properly handle GPUs without CRTCs --- backend/drm/drm.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'backend') diff --git a/backend/drm/drm.c b/backend/drm/drm.c index b9ab7f82..19dad63d 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -156,6 +156,11 @@ bool init_drm_resources(struct wlr_drm_backend *drm) { wlr_log(WLR_INFO, "Found %d DRM CRTCs", res->count_crtcs); drm->num_crtcs = res->count_crtcs; + if (drm->num_crtcs == 0) { + drmModeFreeResources(res); + return true; + } + drm->crtcs = calloc(drm->num_crtcs, sizeof(drm->crtcs[0])); if (!drm->crtcs) { wlr_log_errno(WLR_ERROR, "Allocation failed"); -- cgit v1.2.3 From 37de179013987ae56ef40cc2cccf570e3b1a0351 Mon Sep 17 00:00:00 2001 From: emersion Date: Sun, 7 Oct 2018 13:04:52 +0200 Subject: backend/drm: fix zero-length VLAs --- backend/drm/drm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'backend') diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 19dad63d..272a168c 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -438,9 +438,9 @@ static void realloc_planes(struct wlr_drm_backend *drm, const uint32_t *crtc_in, continue; } - uint32_t possible[drm->num_type_planes[type]]; - uint32_t crtc[drm->num_crtcs]; - uint32_t crtc_res[drm->num_crtcs]; + uint32_t possible[drm->num_type_planes[type] + 1]; + uint32_t crtc[drm->num_crtcs + 1]; + uint32_t crtc_res[drm->num_crtcs + 1]; for (size_t i = 0; i < drm->num_type_planes[type]; ++i) { possible[i] = drm->type_planes[type][i].possible_crtcs; @@ -1165,7 +1165,7 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) { } } - bool changed_outputs[wl_list_length(&drm->outputs)]; + bool changed_outputs[wl_list_length(&drm->outputs) + 1]; memset(changed_outputs, false, sizeof(changed_outputs)); for (size_t i = 0; i < new_outputs_len; ++i) { struct wlr_drm_connector *conn = new_outputs[i]; -- cgit v1.2.3