diff options
author | lstewart <lstewart@FreeBSD.org> | 2013-05-24 00:49:12 +0000 |
---|---|---|
committer | lstewart <lstewart@FreeBSD.org> | 2013-05-24 00:49:12 +0000 |
commit | f3f987c0663f4b51385980c0fe61e5944e80b794 (patch) | |
tree | c0e6b207fc1c7b977b7fb0818731ac778e9ee69f /sys/kern | |
parent | 37dcf710d19543462c119ba640fee8b6d67a88ff (diff) | |
download | FreeBSD-src-f3f987c0663f4b51385980c0fe61e5944e80b794.zip FreeBSD-src-f3f987c0663f4b51385980c0fe61e5944e80b794.tar.gz |
Ensure alq's shutdown_pre_sync event handler is deregistered on module unload to
avoid a dangling pointer and eventual panic on system shutdown.
Reported by: Ali <comnetboy at gmail.com>
Tested by: Ali <comnetboy at gmail.com>
MFC after: 1 week
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_alq.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/kern/kern_alq.c b/sys/kern/kern_alq.c index 893d2f8..daf4e46 100644 --- a/sys/kern/kern_alq.c +++ b/sys/kern/kern_alq.c @@ -99,6 +99,7 @@ static LIST_HEAD(, alq) ald_active; static int ald_shutingdown = 0; struct thread *ald_thread; static struct proc *ald_proc; +static eventhandler_tag alq_eventhandler_tag = NULL; #define ALD_LOCK() mtx_lock(&ald_mtx) #define ALD_UNLOCK() mtx_unlock(&ald_mtx) @@ -194,8 +195,8 @@ ald_daemon(void) ald_thread = FIRST_THREAD_IN_PROC(ald_proc); - EVENTHANDLER_REGISTER(shutdown_pre_sync, ald_shutdown, NULL, - SHUTDOWN_PRI_FIRST); + alq_eventhandler_tag = EVENTHANDLER_REGISTER(shutdown_pre_sync, + ald_shutdown, NULL, SHUTDOWN_PRI_FIRST); ALD_LOCK(); @@ -228,6 +229,8 @@ ald_shutdown(void *arg, int howto) { struct alq *alq; + EVENTHANDLER_DEREGISTER(shutdown_pre_sync, alq_eventhandler_tag); + ALD_LOCK(); /* Ensure no new queues can be created. */ |