From 331c2f4b7e48eb9cd451c3a9b27a664cb01d379a Mon Sep 17 00:00:00 2001 From: Asahi Lina Date: Wed, 7 Dec 2022 18:33:46 +0900 Subject: [PATCH] asahi: Do not leak staging resources for PIPE_MAP_READ We were only dereferencing the resource in the PIPE_MAP_WRITE path of agx_transfer_unmap, which means that read-only transfers leaked the staging resource/BO. Always free the staging resource unconditionally. Signed-off-by: Asahi Lina Part-of: --- src/gallium/drivers/asahi/agx_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index d039e77dc26..a567d43277b 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -845,7 +845,6 @@ agx_transfer_unmap(struct pipe_context *pctx, agx_blit_from_staging(pctx, trans); agx_flush_readers(agx_context(pctx), agx_resource(trans->staging.rsrc), "GPU write staging blit"); - pipe_resource_reference(&trans->staging.rsrc, NULL); } else if (trans->map && (transfer->usage & PIPE_MAP_WRITE)) { assert(rsrc->modifier == DRM_FORMAT_MOD_APPLE_TWIDDLED); @@ -869,6 +868,7 @@ agx_transfer_unmap(struct pipe_context *pctx, /* Free the transfer */ free(trans->map); + pipe_resource_reference(&trans->staging.rsrc, NULL); pipe_resource_reference(&transfer->resource, NULL); FREE(transfer); }