modesetting: Fix front_bo leak at drmmode_xf86crtc_resize on XRandR rotation

Since the introduction of "modesetting: Remove unnecessary fb addition from
drmmode_xf86crtc_resize" the fb_id isn't initialited at

Rotate operation of XRandR uses rotate_bo. So in this case the fb_id
associated to the front_bo is not initialized at drmmode_set_mode_major.
So fd_id remains 0.

As every call to drmmode_xf86crtc_resize allocates a new front_bo we should
destroy unconditionally the old_front_bo if operation success. So we free
the allocated GBM handles.

This avoids crashing xserver with a OOM in the RPI4 1Gb at 4k resolution
after 3 series xrandr rotations from normal to left and vice versa reported at

Signed-off-by: Jose Maria Casanova Crespo <>
Reviewed-by: Keith Packard <>
Closes: xorg/xserver#1024
Fixes: 87745321 "modesetting: Remove unnecessary fb addition from
4 jobs for fix-front_bo-leak in 5 minutes and 58 seconds (queued for 1 second)
Status Name Job ID Coverage
  Docker Image
passed debian-testing #3325936


  Build And Test
passed autotools #3325937


passed meson #3325938


passed meson-noglamor #3325939