Module: Mesa
Branch: master
Commit: e02e1ccbeedf0082e0440b557f21ea9bc4c46173
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e02e1ccbeedf0082e0440b557f21ea9bc4c46173

Author: Tapani Pälli <[email protected]>
Date:   Mon Oct 26 20:51:25 2020 +0200

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: 99cf9108340 ("mesa/st: Actually free the driver part of memory objects 
on destruction.")
Signed-off-by: Tapani Pälli <[email protected]>
Reviewed-by: Lionel Landwerlin <[email protected]>
Reviewed-by: Eleni Maria Stea <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7403>

---

 src/mesa/state_tracker/st_cb_memoryobjects.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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);
 }
 

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to