Skip to content

Commit

Permalink
Merge pull request #1686 from relapids/ppc_leak
Browse files Browse the repository at this point in the history
Fix memory leak in PPC target. (#1680)
  • Loading branch information
wtdcode authored Aug 16, 2022
2 parents 336425b + a3ccbf2 commit 3c17f7c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions qemu/target/ppc/unicorn.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ static void ppc_release(void *ctx)
int i;
TCGContext *tcg_ctx = (TCGContext *)ctx;
PowerPCCPU *cpu = (PowerPCCPU *)tcg_ctx->uc->cpu;
CPUPPCState *env = &cpu->env;
CPUTLBDesc *d = cpu->neg.tlb.d;
CPUTLBDescFast *f = cpu->neg.tlb.f;
CPUTLBDesc *desc;
Expand All @@ -132,6 +133,20 @@ static void ppc_release(void *ctx)

// g_free(tcg_ctx->tb_ctx.tbs);

if (env->nb_tlb != 0) {
switch(env->tlb_type) {
case TLB_6XX:
g_free(env->tlb.tlb6);
break;
case TLB_EMB:
g_free(env->tlb.tlbe);
break;
case TLB_MAS:
g_free(env->tlb.tlbm);
break;
}
}

ppc_cpu_instance_finalize(tcg_ctx->uc->cpu);
ppc_cpu_unrealize(tcg_ctx->uc->cpu);
}
Expand Down

0 comments on commit 3c17f7c

Please # to comment.