Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 May 2013 00:49:12 +0000 (UTC)
From:      Lawrence Stewart <lstewart@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r250951 - head/sys/kern
Message-ID:  <201305240049.r4O0nCrw059316@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: lstewart
Date: Fri May 24 00:49:12 2013
New Revision: 250951
URL: http://svnweb.freebsd.org/changeset/base/250951

Log:
  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

Modified:
  head/sys/kern/kern_alq.c

Modified: head/sys/kern/kern_alq.c
==============================================================================
--- head/sys/kern/kern_alq.c	Thu May 23 22:52:21 2013	(r250950)
+++ head/sys/kern/kern_alq.c	Fri May 24 00:49:12 2013	(r250951)
@@ -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. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201305240049.r4O0nCrw059316>