pan/midgard: Fix a liveness info leak
authorIcecream95 <ixn@keemail.me>
Sun, 26 Jan 2020 01:59:24 +0000 (14:59 +1300)
committerMarge Bot <eric+marge@anholt.net>
Wed, 29 Jan 2020 12:59:32 +0000 (12:59 +0000)
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
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

index b1b2f311ffafdcf76a7809589185fe5c9306ad44..fd93339ed9437382ce45e8f161ffa097548bbfc7 100644 (file)
@@ -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;