git: c8fc5451c39e - main - amd64/pt.c: Plug a 'pt_backend_alloc_thread' error path memory leak

From: Bojan Novković <bnovkov_at_FreeBSD.org>
Date: Tue, 17 Nov 2026 17:44:43 UTC
The branch main has been updated by bnovkov:

URL: https://cgit.FreeBSD.org/src/commit/?id=c8fc5451c39e31c1ebf39b477cb4265ed0545d24

commit c8fc5451c39e31c1ebf39b477cb4265ed0545d24
Author:     Bojan Novković <bnovkov@FreeBSD.org>
AuthorDate: 2026-11-07 13:11:04 +0000
Commit:     Bojan Novković <bnovkov@FreeBSD.org>
CommitDate: 2026-11-17 17:41:14 +0000

    amd64/pt.c: Plug a 'pt_backend_alloc_thread' error path memory leak
    
    The thread-mode allocation method failed to release the previously
    allocate `pt_ctx` structure on error.
    
    Fixes:  310162ea218a
---
 sys/amd64/pt/pt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/amd64/pt/pt.c b/sys/amd64/pt/pt.c
index 20db2447fa43..62e5f7ad7d83 100644
--- a/sys/amd64/pt/pt.c
+++ b/sys/amd64/pt/pt.c
@@ -699,8 +699,10 @@ pt_backend_alloc_thread(struct hwt_thread *thr)
 		return (ENOMEM);
 
 	error = pt_init_ctx(pt_ctx, thr->vm, thr->thread_id);
-	if (error)
+	if (error) {
+		free(pt_ctx, M_PT);
 		return (error);
+	}
 
 	thr->private = pt_ctx;
 	return (0);