From 6ef99f0b5832d2f3e57d78bc3a46a7a2877d96cd Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Mon, 17 Feb 2020 14:37:37 +0000 Subject: Use m_defrag() to linearize an mbuf chain instead of hand rolling a solution which is not bug free. OK stsp@ --- sys/dev/ic/ar5008.c | 18 ++---------------- 1 file 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 @@ -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); -- cgit v1.2.3