svn commit: r222550 - head/sys/kern

Kenneth D. Merry ken at FreeBSD.org
Tue May 31 22:39:32 UTC 2011


Author: ken
Date: Tue May 31 22:39:32 2011
New Revision: 222550
URL: http://svn.freebsd.org/changeset/base/222550

Log:
  Fix a bug introduced in revision 222537.
  
  In msgbuf_reinit() and msgbuf_init(), we weren't initializing the mutex.
  Depending on the contents of memory, the LO_INITIALIZED flag might be
  set on the mutex (either due to a warm reboot, and the message buffer
  remaining in place, or due to garbage in memory) and in that case, with
  INVARIANTS turned on, we would trigger an assertion that the mutex had
  already been initialized.
  
  Fix this by bzeroing the message buffer mutex for the _init() and _reinit()
  paths.
  
  Reported by:	mdf

Modified:
  head/sys/kern/subr_msgbuf.c

Modified: head/sys/kern/subr_msgbuf.c
==============================================================================
--- head/sys/kern/subr_msgbuf.c	Tue May 31 21:42:34 2011	(r222549)
+++ head/sys/kern/subr_msgbuf.c	Tue May 31 22:39:32 2011	(r222550)
@@ -61,6 +61,7 @@ msgbuf_init(struct msgbuf *mbp, void *pt
 	mbp->msg_magic = MSG_MAGIC;
 	mbp->msg_lastpri = -1;
 	mbp->msg_needsnl = 0;
+	bzero(&mbp->msg_lock, sizeof(mbp->msg_lock));
 	mtx_init(&mbp->msg_lock, "msgbuf", NULL, MTX_SPIN);
 }
 
@@ -95,6 +96,7 @@ msgbuf_reinit(struct msgbuf *mbp, void *
 	mbp->msg_lastpri = -1;
 	/* Assume that the old message buffer didn't end in a newline. */
 	mbp->msg_needsnl = 1;
+	bzero(&mbp->msg_lock, sizeof(mbp->msg_lock));
 	mtx_init(&mbp->msg_lock, "msgbuf", NULL, MTX_SPIN);
 }
 


More information about the svn-src-all mailing list