From e94f1fc304e74fbcd9e8354b6f59cf43b4563c91 Mon Sep 17 00:00:00 2001 From: Patrick Lerda Date: Fri, 23 Feb 2024 23:47:51 +0100 Subject: [PATCH] r300: fix r300_destroy_context() related memory leaks For instance, with "piglit/bin/fcc-blit-between-clears -auto -fbo"": SUMMARY: AddressSanitizer: 70512 byte(s) leaked in 497 allocation(s). Fixes: e01f86c67b0b ("r300: set PIPE_BIND_CONSTANT_BUFFER for const_uploader") Signed-off-by: Patrick Lerda Part-of: (cherry picked from commit b11ecacb9377240a81c24bc0eca3a110f9642bc3) --- .pick_status.json | 2 +- src/gallium/drivers/r300/r300_context.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index e3a634bb8d9..dee7c490725 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1694,7 +1694,7 @@ "description": "r300: fix r300_destroy_context() related memory leaks", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "e01f86c67b0bd955758366827cb8322aa1bec263", "notes": null diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index f77a6d6e97d..433f669b58a 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -93,6 +93,8 @@ static void r300_destroy_context(struct pipe_context* context) u_upload_destroy(r300->uploader); if (r300->context.stream_uploader) u_upload_destroy(r300->context.stream_uploader); + if (r300->context.const_uploader) + u_upload_destroy(r300->context.const_uploader); /* XXX: This function assumes r300->query_list was initialized */ r300_release_referenced_objects(r300); @@ -102,6 +104,7 @@ static void r300_destroy_context(struct pipe_context* context) r300->rws->ctx_destroy(r300->ctx); rc_destroy_regalloc_state(&r300->fs_regalloc_state); + rc_destroy_regalloc_state(&r300->vs_regalloc_state); /* XXX: No way to tell if this was initialized or not? */ slab_destroy_child(&r300->pool_transfers); @@ -128,6 +131,9 @@ static void r300_destroy_context(struct pipe_context* context) FREE(r300->vertex_stream_state.state); } } + + FREE(r300->stencilref_fallback); + FREE(r300); }