aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2017-07-09 22:57:00 +0000
committerMark Johnston <markj@FreeBSD.org>2017-07-09 22:57:00 +0000
commitabf5c031bbd87d5276e6476dc84c3c3a42e75fd9 (patch)
treef8e8fd8bc331867b88cf60b008f886163f9330a0
parent8ee96d1452c6b93767920a59035d4cb66a6a6b68 (diff)
downloadsrc-abf5c031bbd87d5276e6476dc84c3c3a42e75fd9.tar.gz
src-abf5c031bbd87d5276e6476dc84c3c3a42e75fd9.zip
Free existing per-thread task structs when unloading linuxkpi.ko.
They are otherwise leaked. Reported and tested by: ae MFC after: 1 week
Notes
Notes: svn path=/head/; revision=320852
-rw-r--r--sys/compat/linuxkpi/common/src/linux_current.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/src/linux_current.c b/sys/compat/linuxkpi/common/src/linux_current.c
index f0d1e199e816..331f6e2d2b7a 100644
--- a/sys/compat/linuxkpi/common/src/linux_current.c
+++ b/sys/compat/linuxkpi/common/src/linux_current.c
@@ -226,6 +226,23 @@ SYSINIT(linux_current, SI_SUB_EVENTHANDLER, SI_ORDER_SECOND, linux_current_init,
static void
linux_current_uninit(void *arg __unused)
{
+ struct proc *p;
+ struct task_struct *ts;
+ struct thread *td;
+
+ sx_slock(&allproc_lock);
+ FOREACH_PROC_IN_SYSTEM(p) {
+ PROC_LOCK(p);
+ FOREACH_THREAD_IN_PROC(p, td) {
+ if ((ts = td->td_lkpi_task) != NULL) {
+ td->td_lkpi_task = NULL;
+ put_task_struct(ts);
+ }
+ }
+ PROC_UNLOCK(p);
+ }
+ sx_sunlock(&allproc_lock);
+
EVENTHANDLER_DEREGISTER(thread_dtor, linuxkpi_thread_dtor_tag);
}
SYSUNINIT(linux_current, SI_SUB_EVENTHANDLER, SI_ORDER_SECOND, linux_current_uninit, NULL);