Skip to content

xwayland: Do not remove output on withdraw if leased

On DRM lease connector withdrawn event, Xwayland would free the corresponding xwl_output offered for lease.

However, the pointer is still referenced from the rrLease->outputs[], meaning that trying to clean up the RANDR DRM leases as done with commit ef181265 (xwayland: Clean up drm lease when terminating) would cause a use after free and random crashes.

To avoid that issue, on the connector withdraw event, set the connector withdrawn flag but do not to remove (i.e. free) the xwayland output if its is offered for lease.

Then, once the lease is terminated, check for the xwl_outputs with a withdrawn connector and remove them (once we have no use for them anymore.

Note that we cannot do that cleanup from xwl_randr_terminate_lease() as removing the xwl_output will free the RRcrtc resources, which checks for leases in XRANDR, and calls RRTerminateLease(), which chains back to xwl_randr_terminate_lease().

v2: Use the connector withdrawn flag to mark outputs to remove (Xaver)

fixes: ef181265 - xwayland: Clean up drm lease when terminating
See-also: #946
See-also: !1130 (merged)

Edited by Olivier Fourdan

Merge request reports

Loading