git: e67b4c879ae1 - stable/14 - hwpmc: release a PMC whose ID could not be copied out
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 09 Nov 2026 16:08:47 UTC
The branch stable/14 has been updated by mhorne:
URL: https://cgit.FreeBSD.org/src/commit/?id=e67b4c879ae16264915de6b5945f7b41bccdd14c
commit e67b4c879ae16264915de6b5945f7b41bccdd14c
Author: Andre Silva <andasilv@amd.com>
AuthorDate: 2026-11-06 15:20:08 +0000
Commit: Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2026-11-09 16:08:04 +0000
hwpmc: release a PMC whose ID could not be copied out
If copyout of the newly allocated PMC ID fails, the caller cannot use or
release the PMC. Release it in the kernel.
Reviewed by: mhorne
MFC after: 3 days
Sponsored by: Advanced Micro Devices, Inc.
Differential Revision: https://reviews.freebsd.org/D60562
(cherry picked from commit e5a48c8e0dd026ba953cf401c4dec02f76078aa2)
---
sys/dev/hwpmc/hwpmc_mod.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c
index 31f1805412db..a5725468e47f 100644
--- a/sys/dev/hwpmc/hwpmc_mod.c
+++ b/sys/dev/hwpmc/hwpmc_mod.c
@@ -4280,6 +4280,12 @@ pmc_syscall_handler(struct thread *td, void *syscall_args)
break;
error = copyout(&pa, arg, sizeof(pa));
+ /*
+ * The caller never learns the ID of an unpublished PMC; do
+ * not leave it (and the row it holds) behind.
+ */
+ if (error != 0)
+ (void)pmc_do_op_pmcrelease(pa.pm_pmcid);
}
break;