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: dd7ae41091 ("egl/gbm: Destroy excess BOs")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42111>
This commit is contained in:
Michel Dänzer 2026-06-09 09:56:55 +02:00 committed by Marge Bot
parent 519f631e6b
commit 962fd789c8

View file

@ -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) {