git: dd70f2b48c9c - stable/13 - hwpmc_arm64: plug memory leak
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 11 Sep 2023 22:44:25 UTC
The branch stable/13 has been updated by mhorne:
URL: https://cgit.FreeBSD.org/src/commit/?id=dd70f2b48c9c0235e52721c2a6930285c3b6939e
commit dd70f2b48c9c0235e52721c2a6930285c3b6939e
Author: Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2023-08-03 14:09:48 +0000
Commit: Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2023-09-11 22:43:59 +0000
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
(cherry picked from commit 8bdceaecabd91ce5ed23646d91cef878681e19d6)
---
sys/dev/hwpmc/hwpmc_arm64.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/sys/dev/hwpmc/hwpmc_arm64.c b/sys/dev/hwpmc/hwpmc_arm64.c
index f0a487cf7d21..65f55108cecb 100644
--- a/sys/dev/hwpmc/hwpmc_arm64.c
+++ b/sys/dev/hwpmc/hwpmc_arm64.c
@@ -452,7 +452,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);
@@ -493,10 +493,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);
}
@@ -588,5 +594,7 @@ pmc_arm64_initialize(void)
void
pmc_arm64_finalize(struct pmc_mdep *md)
{
+ PMCDBG0(MDP, INI, 1, "arm64-finalize");
+ free(arm64_pcpu, M_PMC);
}