From 2420bfef0b104d9fa1152b63661e1fb0cf05bb41 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 6 May 2025 16:01:00 +0100 Subject: [PATCH] backend/drm: Fix segfault in libliftoff startup With labwc and WLR_DRM_FORCE_LIBLIFTOFF=1, a segfault is seen on startup because we call output_state_get_buffer_src_box() when there is no buffer set in the output state. Fix this by getting the src/dst box from state->primary_viewport instead. --- backend/drm/libliftoff.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/backend/drm/libliftoff.c b/backend/drm/libliftoff.c index a5bace015..12761afd4 100644 --- a/backend/drm/libliftoff.c +++ b/backend/drm/libliftoff.c @@ -331,17 +331,16 @@ static bool add_connector(drmModeAtomicReq *req, if (crtc->props.vrr_enabled != 0) { ok = ok && add_prop(req, crtc->id, crtc->props.vrr_enabled, state->vrr_enabled); } - struct wlr_fbox src_box; - struct wlr_box dst_box; - output_state_get_buffer_src_box(state->base, &src_box); - output_state_get_buffer_dst_box(state->base, &dst_box); - ok = ok && - set_plane_props(crtc->primary, crtc->primary->liftoff_layer, - state->primary_fb, 0, &dst_box, &src_box); - ok = ok && - set_plane_props(crtc->primary, crtc->liftoff_composition_layer, - state->primary_fb, 0, &dst_box, &src_box); + ok = ok && set_plane_props(crtc->primary, + crtc->primary->liftoff_layer, state->primary_fb, 0, + &state->primary_viewport.dst_box, + &state->primary_viewport.src_box); + ok = ok && set_plane_props(crtc->primary, + crtc->liftoff_composition_layer, state->primary_fb, 0, + &state->primary_viewport.dst_box, + &state->primary_viewport.src_box); + liftoff_layer_set_property(crtc->primary->liftoff_layer, "FB_DAMAGE_CLIPS", state->fb_damage_clips); liftoff_layer_set_property(crtc->liftoff_composition_layer,