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
This commit is contained in:
Andre Silva authored and Mitchell Horne committed 2026-11-06 11:21:45 -04:00
1 parent fdfb611461
commit e5a48c8e0d
1 file changed
+6
+6
View File
@@ -4367,6 +4367,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;