summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_msgbuf.c
diff options
context:
space:
mode:
authorken <ken@FreeBSD.org>2011-05-31 22:39:32 +0000
committerken <ken@FreeBSD.org>2011-05-31 22:39:32 +0000
commit9237f32b34cedc6002df3ddaf8c875dae5ef325c (patch)
tree66b4b644d58911cf99c6488b5ee1dd3126f9e763 /sys/kern/subr_msgbuf.c
parentdad6aab353f85a0e9219979a0dcbb062fdcb7d29 (diff)
downloadFreeBSD-src-9237f32b34cedc6002df3ddaf8c875dae5ef325c.zip
FreeBSD-src-9237f32b34cedc6002df3ddaf8c875dae5ef325c.tar.gz
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
Diffstat (limited to 'sys/kern/subr_msgbuf.c')
-rw-r--r--sys/kern/subr_msgbuf.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/kern/subr_msgbuf.c b/sys/kern/subr_msgbuf.c
index c146ab0..cd9c551 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);
}
OpenPOWER on IntegriCloud