diff options
author | glebius <glebius@FreeBSD.org> | 2016-05-17 23:15:16 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2016-05-17 23:15:16 +0000 |
commit | 30f7e6f500b5f28d689291839ed0912227ed097e (patch) | |
tree | 991d514c2b6c3c3ee927b73d165a1b8f5d557c7d | |
parent | 60e4daddc371c4595af115df7b2942e1287ab6f0 (diff) | |
download | FreeBSD-src-30f7e6f500b5f28d689291839ed0912227ed097e.zip FreeBSD-src-30f7e6f500b5f28d689291839ed0912227ed097e.tar.gz |
Add a comment and KASSERT that a M_NOFREE mbuf has always EXT_EXTREF ext.
Submitted by: kmacy
-rw-r--r-- | sys/kern/kern_mbuf.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index 273196b..1a369b6 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -638,9 +638,16 @@ mb_free_ext(struct mbuf *m) * Check if the header is embedded in the cluster. It is * important that we can't touch any of the mbuf fields * after we have freed the external storage, since mbuf - * could have been embedded in it. + * could have been embedded in it. For now, the mbufs + * embedded into the cluster are always of type EXT_EXTREF, + * and for this type we won't free the mref. */ - freembuf = (m->m_flags & M_NOFREE) ? 0 : 1; + if (m->m_flags & M_NOFREE) { + freembuf = 0; + KASSERT(m->m_ext.ext_type == EXT_EXTREF, + ("%s: no-free mbuf %p has wrong type", __func__, m)); + } else + freembuf = 1; /* Free attached storage if this mbuf is the only reference to it. */ if (*refcnt == 1 || atomic_fetchadd_int(refcnt, -1) == 1) { |