mirror of
https://github.com/opnsense/src.git
synced 2026-06-03 13:58:30 -04:00
hwpmc_arm64: plug memory leak
Free allocated per-CPU structures in the pcpu_fini and finalize methods. While here, add debug trace entries to these methods. Reviewed by: jkoshy, andrew MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41268
This commit is contained in:
parent
32e47f6272
commit
8bdceaecab
1 changed files with 9 additions and 1 deletions
|
|
@ -450,7 +450,7 @@ arm64_pcpu_init(struct pmc_mdep *md, int cpu)
|
|||
|
||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
||||
("[arm64,%d] wrong cpu number %d", __LINE__, cpu));
|
||||
PMCDBG1(MDP, INI, 1, "arm64-init cpu=%d", cpu);
|
||||
PMCDBG0(MDP, INI, 1, "arm64-pcpu-init");
|
||||
|
||||
arm64_pcpu[cpu] = pac = malloc(sizeof(struct arm64_cpu), M_PMC,
|
||||
M_WAITOK | M_ZERO);
|
||||
|
|
@ -491,10 +491,16 @@ arm64_pcpu_fini(struct pmc_mdep *md, int cpu)
|
|||
{
|
||||
uint32_t pmcr;
|
||||
|
||||
PMCDBG0(MDP, INI, 1, "arm64-pcpu-fini");
|
||||
|
||||
pmcr = arm64_pmcr_read();
|
||||
pmcr &= ~PMCR_E;
|
||||
arm64_pmcr_write(pmcr);
|
||||
|
||||
free(arm64_pcpu[cpu]->pc_arm64pmcs, M_PMC);
|
||||
free(arm64_pcpu[cpu], M_PMC);
|
||||
arm64_pcpu[cpu] = NULL;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
@ -605,5 +611,7 @@ pmc_arm64_initialize(void)
|
|||
void
|
||||
pmc_arm64_finalize(struct pmc_mdep *md)
|
||||
{
|
||||
PMCDBG0(MDP, INI, 1, "arm64-finalize");
|
||||
|
||||
free(arm64_pcpu, M_PMC);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue