summaryrefslogtreecommitdiff
path: root/sys/kern/uipc_mbuf.c
diff options
context:
space:
mode:
authorBret Lambert <blambert@cvs.openbsd.org>2011-04-05 11:48:29 +0000
committerBret Lambert <blambert@cvs.openbsd.org>2011-04-05 11:48:29 +0000
commit94443e3a8469c3b4270194ffd9a06c03702ce903 (patch)
treea3ac085f92f3f31be825d2ee4b46a3cc2dda8a61 /sys/kern/uipc_mbuf.c
parenta5b5f8337f372b5773fb995fbbf744d56eb5e396 (diff)
Passing M_WAITOK to mbuf functions is supposed to be a contract between
the caller and the function that the function will not fail to allocate memory and return a NULL pointer. However, m_dup_pkthdr() violates this contract, making it possible for functions that pass M_WAITOK to be surprised in ways that hurt. Fix this by passing the wait flag all the way down the functions that actually do the allocation for m_dup_pkthdr() so that we won't be surprised. man page update forthcoming ok claudio@
Diffstat (limited to 'sys/kern/uipc_mbuf.c')
-rw-r--r--sys/kern/uipc_mbuf.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 724995ab336..af6894429de 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.151 2011/04/05 01:28:05 art Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.152 2011/04/05 11:48:28 blambert Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -662,7 +662,7 @@ m_copym0(struct mbuf *m0, int off, int len, int wait, int deep)
if (n == NULL)
goto nospace;
if (copyhdr) {
- if (m_dup_pkthdr(n, m0))
+ if (m_dup_pkthdr(n, m0, wait))
goto nospace;
if (len != M_COPYALL)
n->m_pkthdr.len = len;
@@ -1149,7 +1149,7 @@ m_split_mbuf(struct mbuf *m, int off, int wait, struct mbuf *mhdr)
}
}
- if (copyhdr && m_dup_pkthdr(mhdr, n)) {
+ if (copyhdr && m_dup_pkthdr(mhdr, n, wait)) {
m_free(n);
return (NULL);
}
@@ -1346,7 +1346,7 @@ m_trailingspace(struct mbuf *m)
* from must have M_PKTHDR set, and to must be empty.
*/
int
-m_dup_pkthdr(struct mbuf *to, struct mbuf *from)
+m_dup_pkthdr(struct mbuf *to, struct mbuf *from, int wait)
{
int error;
@@ -1358,7 +1358,7 @@ m_dup_pkthdr(struct mbuf *to, struct mbuf *from)
SLIST_INIT(&to->m_pkthdr.tags);
- if ((error = m_tag_copy_chain(to, from)) != 0)
+ if ((error = m_tag_copy_chain(to, from, wait)) != 0)
return (error);
if ((to->m_flags & M_EXT) == 0)