From 3ed72705b3c5417b7dcecb0bdbb1e0fa63a6571c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Mon, 26 Oct 2020 20:51:25 +0200 Subject: [PATCH] mesa/st: call memobj_destroy only if there is memory imported MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: 99cf9108340 ("mesa/st: Actually free the driver part of memory objects on destruction.") Signed-off-by: Tapani Pälli Reviewed-by: Lionel Landwerlin Reviewed-by: Eleni Maria Stea Part-of: (cherry picked from commit e02e1ccbeedf0082e0440b557f21ea9bc4c46173) --- .pick_status.json | 2 +- src/mesa/state_tracker/st_cb_memoryobjects.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index e117817f75a..be8a06de0f2 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -5143,7 +5143,7 @@ "description": "mesa/st: call memobj_destroy only if there is memory imported", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "99cf9108340c2ccf7c1b05ec6f951e2e91b9c76c" }, diff --git a/src/mesa/state_tracker/st_cb_memoryobjects.c b/src/mesa/state_tracker/st_cb_memoryobjects.c index 3ef316a45f8..917e39a91dc 100644 --- a/src/mesa/state_tracker/st_cb_memoryobjects.c +++ b/src/mesa/state_tracker/st_cb_memoryobjects.c @@ -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); }