diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2020-02-17 14:37:37 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2020-02-17 14:37:37 +0000 |
commit | 6ef99f0b5832d2f3e57d78bc3a46a7a2877d96cd (patch) | |
tree | 59639424b0d84d225d27d556bd89b5cc9cdaa6fa | |
parent | 3de014b94044300f4f1606ebd639ecf84131e41d (diff) |
Use m_defrag() to linearize an mbuf chain instead of hand rolling a solution
which is not bug free.
OK stsp@
-rw-r--r-- | sys/dev/ic/ar5008.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/sys/dev/ic/ar5008.c b/sys/dev/ic/ar5008.c index 68f9df5c967..9dd0499c970 100644 --- a/sys/dev/ic/ar5008.c +++ b/sys/dev/ic/ar5008.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5008.c,v 1.54 2020/02/17 14:34:19 claudio Exp $ */ +/* $OpenBSD: ar5008.c,v 1.55 2020/02/17 14:37:36 claudio Exp $ */ /*- * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr> @@ -1299,7 +1299,6 @@ ar5008_tx(struct athn_softc *sc, struct mbuf *m, struct ieee80211_node *ni, struct athn_txq *txq; struct athn_tx_buf *bf; struct athn_node *an = (void *)ni; - struct mbuf *m1; uintptr_t entry; uint16_t qos; uint8_t txpower, type, encrtype, tid, ridx[4]; @@ -1423,23 +1422,10 @@ ar5008_tx(struct athn_softc *sc, struct mbuf *m, struct ieee80211_node *ni, * DMA mapping requires too many DMA segments; linearize * mbuf in kernel virtual address space and retry. */ - MGETHDR(m1, M_DONTWAIT, MT_DATA); - if (m1 == NULL) { + if (m_defrag(m, M_DONTWAIT) != 0) { m_freem(m); return (ENOBUFS); } - if (m->m_pkthdr.len > MHLEN) { - MCLGET(m1, M_DONTWAIT); - if (!(m1->m_flags & M_EXT)) { - m_freem(m); - m_freem(m1); - return (ENOBUFS); - } - } - m_copydata(m, 0, m->m_pkthdr.len, mtod(m1, caddr_t)); - m1->m_pkthdr.len = m1->m_len = m->m_pkthdr.len; - m_freem(m); - m = m1; error = bus_dmamap_load_mbuf(sc->sc_dmat, bf->bf_map, m, BUS_DMA_NOWAIT | BUS_DMA_WRITE); |