diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2017-03-30 07:23:51 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2017-03-30 07:23:51 +0000 |
commit | 0971f1a83e024df75094ba8e5f50a3f10ff64bf7 (patch) | |
tree | 2fa29f076efa37f596fa20937efa1bc7529411ed /sys/dev | |
parent | d62b35e59628fb614172f18a6ff2f64952e4cc7c (diff) |
Use m_devget(9) to replace code that does more or less the same but assumes
the received packet fits in a single mbuf cluster, which isn't necessarily
the case. This might fix the pool corruption seen by jcs@.
ok jcs@, jmatthew@, deraadt@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/if_ure.c | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/sys/dev/usb/if_ure.c b/sys/dev/usb/if_ure.c index a9b6b480d12..06ca5eaa247 100644 --- a/sys/dev/usb/if_ure.c +++ b/sys/dev/usb/if_ure.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ure.c,v 1.4 2017/03/11 13:40:46 kettenis Exp $ */ +/* $OpenBSD: if_ure.c,v 1.5 2017/03/30 07:23:50 kettenis Exp $ */ /*- * Copyright (c) 2015-2016 Kevin Lo <kevlo@FreeBSD.org> * All rights reserved. @@ -118,7 +118,6 @@ void ure_rxeof(struct usbd_xfer *, void *, usbd_status); void ure_txeof(struct usbd_xfer *, void *, usbd_status); int ure_rx_list_init(struct ure_softc *); int ure_tx_list_init(struct ure_softc *); -struct mbuf * ure_newbuf(void); void ure_tick_task(void *); void ure_tick(void *); @@ -1299,17 +1298,13 @@ ure_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status status) total_len -= pktlen; buf += sizeof(rxhdr); - m = ure_newbuf(); + m = m_devget(buf, pktlen, ETHER_ALIGN); if (m == NULL) { DPRINTF(("unable to allocate mbuf for next packet\n")); ifp->if_ierrors++; goto done; } - m->m_pkthdr.len = m->m_len = pktlen; - m_adj(m, ETHER_ALIGN); - - memcpy(mtod(m, char *), buf, pktlen); ml_enqueue(&ml, m); } while (total_len > 0); @@ -1430,24 +1425,6 @@ ure_rx_list_init(struct ure_softc *sc) return 0; } -struct mbuf * -ure_newbuf(void) -{ - struct mbuf *m; - - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == NULL) - return NULL; - - MCLGET(m, M_DONTWAIT); - if (!(m->m_flags & M_EXT)) { - m_freem(m); - return NULL; - } - - return m; -} - int ure_encap(struct ure_softc *sc, struct mbuf *m, int idx) { |