mesa/st: call memobj_destroy only if there is memory imported

Something may go wrong during import which leaves pointer to null and
when ctx and it's shared state gets destroyed we will attempt to call
memobj_destroy. Instead of forcing every driver to handle it, add check
here.

Fixes crashes with Piglit test:
   ext_external_objects_fd-memory-object-api-errors

Fixes: 99cf910834 ("mesa/st: Actually free the driver part of memory objects on destruction.")
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Eleni Maria Stea <estea@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7403>
This commit is contained in:
Tapani Pälli 2020-10-26 20:51:25 +02:00 committed by Marge Bot
parent 57c152af9c
commit e02e1ccbee
1 changed files with 2 additions and 1 deletions

View File

@ -59,7 +59,8 @@ st_memoryobj_free(struct gl_context *ctx,
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
screen->memobj_destroy(screen, st_obj->memory);
if (st_obj->memory)
screen->memobj_destroy(screen, st_obj->memory);
_mesa_delete_memory_object(ctx, obj);
}