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

Author: Icecream95 <[email protected]>
Date:   Sun Jan 26 14:59:24 2020 +1300

pan/midgard: Fix a liveness info leak

Reviewed-by: Alyssa Rosenzweig <[email protected]>
Tested-by: Marge Bot 
<https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3566>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3566>

---

 src/panfrost/midgard/midgard_liveness.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/panfrost/midgard/midgard_liveness.c 
b/src/panfrost/midgard/midgard_liveness.c
index b1b2f311ffa..fd93339ed94 100644
--- a/src/panfrost/midgard/midgard_liveness.c
+++ b/src/panfrost/midgard/midgard_liveness.c
@@ -92,7 +92,8 @@ liveness_block_update(compiler_context *ctx, midgard_block 
*blk)
 
         liveness_block_live_out(ctx, blk);
 
-        uint16_t *live = mem_dup(blk->live_out, ctx->temp_count * 
sizeof(uint16_t));
+        uint16_t *live = ralloc_array(ctx, uint16_t, ctx->temp_count);
+        memcpy(live, blk->live_out, ctx->temp_count * sizeof(uint16_t));
 
         mir_foreach_instr_in_block_rev(blk, ins)
                 mir_liveness_ins_update(live, ins, ctx->temp_count);
@@ -102,7 +103,7 @@ liveness_block_update(compiler_context *ctx, midgard_block 
*blk)
         for (unsigned i = 0; (i < ctx->temp_count) && !progress; ++i)
                 progress |= (blk->live_in[i] != live[i]);
 
-        free(blk->live_in);
+        ralloc_free(blk->live_in);
         blk->live_in = live;
 
         return progress;
@@ -131,8 +132,8 @@ mir_compute_liveness(compiler_context *ctx)
         /* Allocate */
 
         mir_foreach_block(ctx, block) {
-                block->live_in = calloc(ctx->temp_count, sizeof(uint16_t));
-                block->live_out = calloc(ctx->temp_count, sizeof(uint16_t));
+                block->live_in = rzalloc_array(ctx, uint16_t, ctx->temp_count);
+                block->live_out = rzalloc_array(ctx, uint16_t, 
ctx->temp_count);
         }
 
         /* Initialize the work list with the exit block */
@@ -183,10 +184,10 @@ mir_invalidate_liveness(compiler_context *ctx)
 
         mir_foreach_block(ctx, block) {
                 if (block->live_in)
-                        free(block->live_in);
+                        ralloc_free(block->live_in);
 
                 if (block->live_out)
-                        free(block->live_out);
+                        ralloc_free(block->live_out);
 
                 block->live_in = NULL;
                 block->live_out = NULL;

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

Reply via email to