summaryrefslogtreecommitdiff
path: root/sys/dev/pci/hifn7751.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2009-09-13 14:42:53 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2009-09-13 14:42:53 +0000
commit72c9514b3fe03e2af58b7386b4ea1b1b8d03bb73 (patch)
treeddd67747f9e94367b396ade568c730dfa795adb5 /sys/dev/pci/hifn7751.c
parent4eef650080d9b8f29430c67e8bfb02019d822601 (diff)
M_DUP_PKTHDR() define -> m_dup_pkthdr() function to properly deal
with m_tag_copy_chain() failures. Use m_defrag() to eliminate hand rolled defragging of mbufs and some uses of M_DUP_PKTHDR(). Original diff from thib@, claudio@'s feedback integrated by me. Tests kevlo@ claudio@, "reads ok" blambert@ ok thib@ claudio@, "m_defrag() bits ok" kettenis@
Diffstat (limited to 'sys/dev/pci/hifn7751.c')
-rw-r--r--sys/dev/pci/hifn7751.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/sys/dev/pci/hifn7751.c b/sys/dev/pci/hifn7751.c
index eca6ee5a872..660c6be6ef3 100644
--- a/sys/dev/pci/hifn7751.c
+++ b/sys/dev/pci/hifn7751.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hifn7751.c,v 1.157 2008/09/25 17:55:28 chl Exp $ */
+/* $OpenBSD: hifn7751.c,v 1.158 2009/09/13 14:42:52 krw Exp $ */
/*
* Invertex AEON / Hifn 7751 driver
@@ -1429,8 +1429,13 @@ hifn_crypto(struct hifn_softc *sc, struct hifn_command *cmd,
err = ENOMEM;
goto err_srcmap;
}
- if (len == MHLEN)
- M_DUP_PKTHDR(m0, cmd->srcu.src_m);
+ if (len == MHLEN) {
+ err = m_dup_pkthdr(m0, cmd->srcu.src_m);
+ if (err) {
+ m_free(m0);
+ goto err_srcmap;
+ }
+ }
if (totlen >= MINCLSIZE) {
MCLGET(m0, M_DONTWAIT);
if (m0->m_flags & M_EXT)
@@ -2752,8 +2757,12 @@ hifn_mkmbuf_chain(int totlen, struct mbuf *mtemplate)
}
if (m0 == NULL)
return (NULL);
- if (len == MHLEN)
- M_DUP_PKTHDR(m0, mtemplate);
+ if (len == MHLEN) {
+ if (m_dup_pkthdr(m0, mtemplate)) {
+ m_free(m0);
+ return (NULL);
+ }
+ }
MCLGET(m0, M_DONTWAIT);
if (!(m0->m_flags & M_EXT))
m_freem(m0);