Skip to content

Commit

Permalink
Merge pull request #1688 from relapids/tricore_leak
Browse files Browse the repository at this point in the history
Fix memory leaks in TriCore target. (#1681)
  • Loading branch information
wtdcode authored Aug 31, 2022
2 parents bc74ea2 + e15173d commit a630028
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion qemu/target/tricore/unicorn.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,25 @@ static int tricore_cpus_init(struct uc_struct *uc, const char *cpu_model)
return 0;
}

static void tricore_release(void *ctx)
{
int i;
TCGContext *tcg_ctx = (TCGContext *)ctx;
TriCoreCPU *cpu = (TriCoreCPU *)tcg_ctx->uc->cpu;
CPUTLBDesc *d = cpu->neg.tlb.d;
CPUTLBDescFast *f = cpu->neg.tlb.f;
CPUTLBDesc *desc;
CPUTLBDescFast *fast;

release_common(ctx);
for (i = 0; i < NB_MMU_MODES; i++) {
desc = &(d[i]);
fast = &(f[i]);
g_free(desc->iotlb);
g_free(fast->table);
}
}

void tricore_uc_init(struct uc_struct *uc)
{
uc->reg_read = tricore_reg_read;
Expand All @@ -271,6 +290,7 @@ void tricore_uc_init(struct uc_struct *uc)
uc->set_pc = tricore_set_pc;
uc->get_pc = tricore_get_pc;
uc->cpus_init = tricore_cpus_init;
uc->release = tricore_release;
uc->cpu_context_size = offsetof(CPUTriCoreState, end_reset_fields);
uc_common_init(uc);
}
}

0 comments on commit a630028

Please # to comment.