From 9be9fd85911883521a31111e728efc0f25b9bacd Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Sun, 26 Jan 2020 14:59:24 +1300 Subject: [PATCH] pan/midgard: Fix a liveness info leak Reviewed-by: Alyssa Rosenzweig Tested-by: Marge Bot Part-of: --- 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; -- 2.30.2