mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
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 commitef181265(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 a "withdrawn_connector" flag to mark outputs to remove (Xaver) Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Xaver Hugl <xaver.hugl@kde.org> fixes:ef181265- xwayland: Clean up drm lease when terminating See-also: https://gitlab.freedesktop.org/xorg/xserver/-/issues/946 See-also: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1130 Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1482> (cherry picked from commit4053782443)