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

Author: Lucas Stach <[email protected]>
Date:   Tue Oct 10 19:29:37 2023 +0200

etnaviv: fix read staging buffer leak

Currently we only free a potentially allocated staging buffer
when the mapping is a write mapping, but staging buffers can
also be allocated for read mappings. Fix the read staging
buffer leaks by always freeing the staging buffer.

Closes #9967

Cc: mesa-stable
Signed-off-by: Lucas Stach <[email protected]>
Reviewed-by: Christian Gmeiner <[email protected]>
Reviewed-by: Emma Anholt <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25646>

---

 src/gallium/drivers/etnaviv/etnaviv_transfer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c 
b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
index 696e74ec418..2027cbbe83f 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
@@ -153,8 +153,6 @@ etna_transfer_unmap(struct pipe_context *pctx, struct 
pipe_transfer *ptrans)
          } else {
             BUG("unsupported tiling %i", rsc->layout);
          }
-
-         FREE(trans->staging);
       }
 
       if (ptrans->resource->target == PIPE_BUFFER)
@@ -179,6 +177,7 @@ etna_transfer_unmap(struct pipe_context *pctx, struct 
pipe_transfer *ptrans)
    if (!trans->rsc && !(ptrans->usage & PIPE_MAP_UNSYNCHRONIZED))
       etna_bo_cpu_fini(rsc->bo);
 
+   FREE(trans->staging);
    pipe_resource_reference(&trans->rsc, NULL);
    pipe_resource_reference(&ptrans->resource, NULL);
    slab_free(&ctx->transfer_pool, trans);

Reply via email to