aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2026-07-24 20:04:45 +0000
committerMark Johnston <markj@FreeBSD.org>2026-07-24 20:04:45 +0000
commitc7917e72fe80e2e168b3812718b5fcd497c0e3b8 (patch)
tree21a33e5238863228cdeff920fe244c08918796b0
parente591a76621430d6d29f2580e2dec8991e450ed5e (diff)
kthread: Fix a thread leak
Fixes: 963629923308 ("kthread_add(): do not allow to attach the thread to a dead or dying process") Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D58433
-rw-r--r--sys/kern/kern_kthread.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c
index cfe2dab2e05c..6650ab868f78 100644
--- a/sys/kern/kern_kthread.c
+++ b/sys/kern/kern_kthread.c
@@ -281,6 +281,7 @@ kthread_add1(void (*func)(void *), void *arg, struct proc *p,
PROC_LOCK(p);
if (p->p_state == PRS_ZOMBIE || (p->p_flag2 & P2_WEXIT) != 0) {
PROC_UNLOCK(p);
+ thread_free(newtd);
return (ESRCH);
}
oldtd = FIRST_THREAD_IN_PROC(p);