From nobody Mon Sep 11 22:44:26 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Rl1x66LQpz4sZkL; Mon, 11 Sep 2023 22:44:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Rl1x640dPz4Hml; Mon, 11 Sep 2023 22:44:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694472266; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=D8lPO/SpbDq2wdt+5GrCnGX4+vuGTfNTeqVg/VxVD7c=; b=gKTbsdUvma1NwU9hNBWOIZAaDoZ94Z1l1Q1tHLrRs2kncAxlA77VHt31t0jT2IomLyGfs5 6EdFxHPonPr2KfthuweWqRYpHms/wIiyHqslyYdo8ueIs/RFU6CPuqVrDABm7F0dAAsLET TRZyAIcs3qyGaEdEqj+4u05mBd06YPt3J4a5vd6v2H+ebLhranJCA6ir1UkW0qDJjSHiYR pMpBuVQqafdzWLuuiiDw7swq56IgsuWc3G3yArH/d2dKXcWRdbVHUqmAfnpAl7C4bhSTvD v1KdK5nA8DEZbex0bNZAD4yCrDRRadG3i7LiykGzkesDtX2f++IzZKPiK7CliQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694472266; a=rsa-sha256; cv=none; b=rx98RGNuxk3XoHunq+/YtZtpadja7428KrRtLGRyGpGLFxYNFY7b/4cLS1/200RyKN5mOh Fxvwp0jewLOkgdt6t2zhJ80IiqFTRYODPXQetbSygzjOh86RKiVWuYTkFZ5SHsBiRCkSdn CXDcm87K4JlZpBjECqjZ84J2cc2fUXZenWJbShy4ULAHAzVEG4TFAvH9PebL59S5WajAnw f48DgJNrqtZFrzwOPJsz0H4gMnnhFBIWd0B2DqLFrA4UogQcbijEqMf6TyLHC1A8DK9t+b E6uhX9RwTeO9NVwofG1cN1dSU/NwTx1CRkAuflL2m+EjugJynN1KwjI5csC+3w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694472266; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=D8lPO/SpbDq2wdt+5GrCnGX4+vuGTfNTeqVg/VxVD7c=; b=Y6YRD3PKnsw3Ig4hsc84M2mzKCXpODGiPW1WqLaEMTyaAsA6Lb7hr4FirZFW1FvcNgdJ0I nN9rdp7y1+HODtpcarfx3UTpL51I6T+o9Z4XbFocwtOzSAuLCd4y6QAx6pALt90SY4xihe W0tgpBKzC9IJiNc7dT2JR6K7FkgaOglnPEwTvPH4vvHm6bmb/FX7N7uN1lVNsa6CrYZ2yz Jv44nbALNAh8OrSrRW0UZQ2+e3baKfpexorjxw25kEPg74pcqE622Xxk/iOcxeRUJpm/Mf 95zaC6L8v2Dp/cM+EElsClauR9IGCVUWkMNUzsxq85mTgt+KdqYw1YPN+fXNvQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Rl1x630pXz16h2; Mon, 11 Sep 2023 22:44:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38BMiQpo073969; Mon, 11 Sep 2023 22:44:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38BMiQP8073966; Mon, 11 Sep 2023 22:44:26 GMT (envelope-from git) Date: Mon, 11 Sep 2023 22:44:26 GMT Message-Id: <202309112244.38BMiQP8073966@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 9f66a42db74e - stable/13 - hwpmc_armv7: plug memory leak List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9f66a42db74ed703f4b590d3e8037ba982f2af20 Auto-Submitted: auto-generated The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=9f66a42db74ed703f4b590d3e8037ba982f2af20 commit 9f66a42db74ed703f4b590d3e8037ba982f2af20 Author: Mitchell Horne AuthorDate: 2023-08-03 14:10:26 +0000 Commit: Mitchell Horne CommitDate: 2023-09-11 22:43:59 +0000 hwpmc_armv7: 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/D41269 (cherry picked from commit 9c0a2d522f3a18fc795a7dd6266d2be2aff4b084) --- sys/dev/hwpmc/hwpmc_armv7.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/dev/hwpmc/hwpmc_armv7.c b/sys/dev/hwpmc/hwpmc_armv7.c index fb4292792bb9..43c662dfcd39 100644 --- a/sys/dev/hwpmc/hwpmc_armv7.c +++ b/sys/dev/hwpmc/hwpmc_armv7.c @@ -417,7 +417,7 @@ armv7_pcpu_init(struct pmc_mdep *md, int cpu) KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[armv7,%d] wrong cpu number %d", __LINE__, cpu)); - PMCDBG1(MDP, INI, 1, "armv7-init cpu=%d", cpu); + PMCDBG0(MDP, INI, 1, "armv7-pcpu-init"); armv7_pcpu[cpu] = pac = malloc(sizeof(struct armv7_cpu), M_PMC, M_WAITOK|M_ZERO); @@ -453,6 +453,8 @@ armv7_pcpu_fini(struct pmc_mdep *md, int cpu) { uint32_t pmnc; + PMCDBG0(MDP, INI, 1, "armv7-pcpu-fini"); + pmnc = cp15_pmcr_get(); pmnc &= ~ARMV7_PMNC_ENABLE; cp15_pmcr_set(pmnc); @@ -462,6 +464,10 @@ armv7_pcpu_fini(struct pmc_mdep *md, int cpu) cp15_pminten_clr(pmnc); cp15_pmovsr_set(pmnc); + free(armv7_pcpu[cpu]->pc_armv7pmcs, M_PMC); + free(armv7_pcpu[cpu], M_PMC); + armv7_pcpu[cpu] = NULL; + return 0; } @@ -532,5 +538,7 @@ pmc_armv7_initialize(void) void pmc_armv7_finalize(struct pmc_mdep *md) { + PMCDBG0(MDP, INI, 1, "armv7-finalize"); + free(armv7_pcpu, M_PMC); }