summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_mbuf.c10
-rw-r--r--sys/sys/mbuf.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/sys/kern/subr_mbuf.c b/sys/kern/subr_mbuf.c
index 5d593e6..5d624f6 100644
--- a/sys/kern/subr_mbuf.c
+++ b/sys/kern/subr_mbuf.c
@@ -1380,6 +1380,11 @@ m_free(struct mbuf *mb)
int cchnum;
short persist = 0;
+#ifdef INVARIANTS
+ if (mb->m_flags & M_FREELIST)
+ panic("m_free detected a mbuf double-free");
+ mb->m_flags |= M_FREELIST;
+#endif
if ((mb->m_flags & M_PKTHDR) != 0)
m_tag_delete_chain(mb, NULL);
nb = mb->m_next;
@@ -1422,6 +1427,11 @@ m_freem(struct mbuf *mb)
short persist;
while (mb != NULL) {
+#ifdef INVARIANTS
+ if (mb->m_flags & M_FREELIST)
+ panic("m_freem detected a mbuf double-free");
+ mb->m_flags |= M_FREELIST;
+#endif
if ((mb->m_flags & M_PKTHDR) != 0)
m_tag_delete_chain(mb, NULL);
persist = 0;
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index a00534a..8a27462 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -153,6 +153,7 @@ struct mbuf {
#define M_PROTO3 0x0040 /* protocol-specific */
#define M_PROTO4 0x0080 /* protocol-specific */
#define M_PROTO5 0x0100 /* protocol-specific */
+#define M_FREELIST 0x4000 /* mbuf is on the free list */
/*
* mbuf pkthdr flags (also stored in m_flags).
OpenPOWER on IntegriCloud