Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 May 2011 22:39:32 +0000 (UTC)
From:      "Kenneth D. Merry" <ken@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r222550 - head/sys/kern
Message-ID:  <201105312239.p4VMdW2A043017@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }
 



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