svn commit: r252323 - stable/9/sys/kern

Lawrence Stewart lstewart at FreeBSD.org
Fri Jun 28 02:38:33 UTC 2013


Author: lstewart
Date: Fri Jun 28 02:38:33 2013
New Revision: 252323
URL: http://svnweb.freebsd.org/changeset/base/252323

Log:
  MFC r250951,251838:
  
  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>

Modified:
  stable/9/sys/kern/kern_alq.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/kern_alq.c
==============================================================================
--- stable/9/sys/kern/kern_alq.c	Fri Jun 28 00:34:39 2013	(r252322)
+++ stable/9/sys/kern/kern_alq.c	Fri Jun 28 02:38:33 2013	(r252323)
@@ -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();
 
@@ -941,6 +942,8 @@ alq_load_handler(module_t mod, int what,
 		if (LIST_FIRST(&ald_queues) == NULL) {
 			ald_shutingdown = 1;
 			ALD_UNLOCK();
+			EVENTHANDLER_DEREGISTER(shutdown_pre_sync,
+			    alq_eventhandler_tag);
 			ald_shutdown(NULL, 0);
 			mtx_destroy(&ald_mtx);
 		} else {


More information about the svn-src-stable-9 mailing list