Module Name: src Committed By: martin Date: Mon Mar 22 18:20:38 UTC 2021
Modified Files: src/sys/dev/usb [netbsd-9]: if_urtwn.c Log Message: Pull up following revision(s) (requested by nat in ticket #1234), all via patch: sys/dev/usb/if_urtwn.c: revision 1.93 sys/dev/usb/if_urtwn.c: revision 1.95 sys/dev/usb/if_urtwn.c: revision 1.96 if_urtwn.c: Plug a few leaks Can be a cause of PR/55968 Also free assocated mbufs. Opps....Remove irrelavent debug code and don't free_m before IFQ_DEQUEUE(). Identified and reported by Patrick Welche and remedy found by Martin Husemann. To generate a diff of this commit: cvs rdiff -u -r1.71.2.4 -r1.71.2.5 src/sys/dev/usb/if_urtwn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/if_urtwn.c diff -u src/sys/dev/usb/if_urtwn.c:1.71.2.4 src/sys/dev/usb/if_urtwn.c:1.71.2.5 --- src/sys/dev/usb/if_urtwn.c:1.71.2.4 Thu Feb 4 19:23:10 2021 +++ src/sys/dev/usb/if_urtwn.c Mon Mar 22 18:20:38 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_urtwn.c,v 1.71.2.4 2021/02/04 19:23:10 martin Exp $ */ +/* $NetBSD: if_urtwn.c,v 1.71.2.5 2021/03/22 18:20:38 martin Exp $ */ /* $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $ */ /*- @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.71.2.4 2021/02/04 19:23:10 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.71.2.5 2021/03/22 18:20:38 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -2563,6 +2563,17 @@ urtwn_rxeof(struct usbd_xfer *xfer, void } static void +urtwn_put_tx_data(struct urtwn_softc *sc, struct urtwn_tx_data *data) +{ + size_t pidx = data->pidx; + + mutex_enter(&sc->sc_tx_mtx); + /* Put this Tx buffer back to our free list. */ + TAILQ_INSERT_TAIL(&sc->tx_free_list[pidx], data, next); + mutex_exit(&sc->sc_tx_mtx); +} + +static void urtwn_txeof(struct usbd_xfer *xfer, void *priv, usbd_status status) { struct urtwn_tx_data *data = priv; @@ -2574,10 +2585,7 @@ urtwn_txeof(struct usbd_xfer *xfer, void DPRINTFN(DBG_FN|DBG_TX, ("%s: %s: status=%d\n", device_xname(sc->sc_dev), __func__, status)); - mutex_enter(&sc->sc_tx_mtx); - /* Put this Tx buffer back to our free list. */ - TAILQ_INSERT_TAIL(&sc->tx_free_list[pidx], data, next); - mutex_exit(&sc->sc_tx_mtx); + urtwn_put_tx_data(sc, data); s = splnet(); sc->tx_timer = 0; @@ -2626,8 +2634,11 @@ urtwn_tx(struct urtwn_softc *sc, struct if (wh->i_fc[1] & IEEE80211_FC1_WEP) { k = ieee80211_crypto_encap(ic, ni, m); - if (k == NULL) + if (k == NULL) { + urtwn_put_tx_data(sc, data); + m_free(m); return ENOBUFS; + } /* packet header may have moved, reset our local pointer */ wh = mtod(m, struct ieee80211_frame *); @@ -2890,14 +2901,17 @@ urtwn_start(struct ifnet *ifp) (m = m_pullup(m, sizeof(*eh))) == NULL) { printf("ERROR6\n"); ifp->if_oerrors++; + urtwn_put_tx_data(sc, data); + m_freem(m); continue; } eh = mtod(m, struct ether_header *); ni = ieee80211_find_txnode(ic, eh->ether_dhost); if (ni == NULL) { - m_freem(m); printf("ERROR5\n"); ifp->if_oerrors++; + urtwn_put_tx_data(sc, data); + m_freem(m); continue; } @@ -2907,6 +2921,8 @@ urtwn_start(struct ifnet *ifp) ieee80211_free_node(ni); printf("ERROR4\n"); ifp->if_oerrors++; + urtwn_put_tx_data(sc, data); + m_freem(m); continue; } sendit: