From 962fd789c82add4ec71e182ec9cd8f6245689d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Tue, 9 Jun 2026 09:56:55 +0200 Subject: [PATCH] egl/gbm: Ignore buffers with no BO for destroying excess BOs Can't destroy a BO that doesn't exist in the first place. Should fix the crash described in https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41845#note_3510521 . Fixes: dd7ae4109189 ("egl/gbm: Destroy excess BOs") Part-of: --- src/egl/drivers/dri2/platform_drm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index e2da328d671..f6fe503290d 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -224,7 +224,8 @@ destroy_oldest_unused_bo(struct dri2_egl_surface *dri2_surf) for (unsigned i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) { struct dri2_egl_buffer *buffer = &dri2_surf->color_buffers[i]; - if (buffer->locked || + if (!buffer->bo || + buffer->locked || buffer == dri2_surf->back || buffer == dri2_surf->current) continue; @@ -253,7 +254,8 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) if (!dri2_surf->color_buffers[i].locked) { int age = dri2_surf->color_buffers[i].age; - if (!min_age || age < min_age) + if (dri2_surf->color_buffers[i].bo && + (!min_age || age < min_age)) min_age = age; if (!max_age || age > max_age) {