diff options
author | glebius <glebius@FreeBSD.org> | 2013-03-17 07:41:14 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2013-03-17 07:41:14 +0000 |
commit | 338f6e587c1344da33c4c32894447d1d4257e330 (patch) | |
tree | 5f315f821b0d06591ac6c9083bb1d3147f51884d /sys/kern | |
parent | 7bcebf010f85ebc9c6893f5aef56eb0a8cd73529 (diff) | |
download | FreeBSD-src-338f6e587c1344da33c4c32894447d1d4257e330.zip FreeBSD-src-338f6e587c1344da33c4c32894447d1d4257e330.tar.gz |
In m_align() add assertions that mbuf is virgin, similar to assertions
in M_ALIGN(), MH_ALIGN, MEXT_ALIGN() macros.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/uipc_mbuf.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 621a3eb..ea4fd80 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -395,7 +395,7 @@ m_demote(struct mbuf *m0, int all) m_freem(m->m_nextpkt); m->m_nextpkt = NULL; } - m->m_flags = m->m_flags & (M_EXT|M_RDONLY|M_FREELIST|M_NOFREE); + m->m_flags = m->m_flags & (M_EXT|M_RDONLY|M_NOFREE); } } @@ -1877,14 +1877,22 @@ m_mbuftouio(struct uio *uio, struct mbuf *m, int len) void m_align(struct mbuf *m, int len) { +#ifdef INVARIANTS + const char *msg = "%s: not a virgin mbuf"; +#endif int adjust; - if (m->m_flags & M_EXT) + if (m->m_flags & M_EXT) { + KASSERT(m->m_data == m->m_ext.ext_buf, (msg, __func__)); adjust = m->m_ext.ext_size - len; - else if (m->m_flags & M_PKTHDR) + } else if (m->m_flags & M_PKTHDR) { + KASSERT(m->m_data == m->m_pktdat, (msg, __func__)); adjust = MHLEN - len; - else + } else { + KASSERT(m->m_data == m->m_dat, (msg, __func__)); adjust = MLEN - len; + } + m->m_data += adjust &~ (sizeof(long)-1); } |