From 2a6ea687ba685b6221a36563437a2d5fc2e8b931 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Thu, 18 Feb 2021 13:51:17 +0200 Subject: [PATCH] gl-renderer: Avoid destroying an egl image if known import failed As observed on some platforms, importing known DMA buffers can cause failures, leading to an attempt of destroyng an EGL image not set. This patch resets the num_images such that loop becomes inert when destroying the DMA buffer, and avoids passing an egl image to it. The initial import doesn't have this issue as it sets the num_images in case it succeeds. This also corrects the assumption that the num_images were 0 at that point which, if the initial import succeded, was actually set to 1. Signed-off-by: Marius Vlad --- libweston/renderer-gl/gl-renderer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index 0d6900fa..f9c8b306 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -2726,9 +2726,13 @@ import_known_dmabuf(struct gl_renderer *gr, switch (image->import_type) { case IMPORT_TYPE_DIRECT: image->images[0] = import_simple_dmabuf(gr, &image->dmabuf->attributes); - if (!image->images[0]) + if (!image->images[0]) { + /* num_images is already set to 1 when doing the intial + * import so reset it to 0 to avoid passing an empty + * egl_image to dmabuf_destroy */ + image->num_images = 0; return false; - image->num_images = 1; + } break; case IMPORT_TYPE_GL_CONVERSION: