From 534917efeff100709a69b71b3e73df48fa2c2019 Mon Sep 17 00:00:00 2001 From: "Kenneth D. Merry" Date: Tue, 31 May 2011 22:39:32 +0000 Subject: 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 --- sys/kern/subr_msgbuf.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sys') diff --git a/sys/kern/subr_msgbuf.c b/sys/kern/subr_msgbuf.c index c146ab0900aed..cd9c551497754 100644 --- a/sys/kern/subr_msgbuf.c +++ b/sys/kern/subr_msgbuf.c @@ -61,6 +61,7 @@ msgbuf_init(struct msgbuf *mbp, void *ptr, int size) 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 *ptr, int size) 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); } -- cgit v1.3