Skip to content

Commit 7bc1a43

Browse files
Pull up following revision(s) (requested by nat in ticket #1158):
sys/dev/usb/if_urtwn.c: revision 1.114 sys/dev/usb/if_urtwn.c: revision 1.115 sys/dev/usb/if_urtwn.c: revision 1.116 sys/dev/usb/if_urtwn.c: revision 1.117 sys/dev/usb/if_urtwn.c: revision 1.113 Set the pipe index on usb xfer creation. Plug an xfer leak in the tx error path. Use the right packet spacing for the 8192EU. From OpenBSD and confrimed by my own analysis. Safety first! Ensure that the receive packet processing does not exceed beyond xfer length. Fix typo. Found by Harold Gutch (hgutch@).
1 parent 2fd4fe8 commit 7bc1a43

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

sys/dev/usb/if_urtwn.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: if_urtwn.c,v 1.105.4.3 2025/07/30 10:54:30 martin Exp $ */
1+
/* $NetBSD: if_urtwn.c,v 1.105.4.4 2025/09/23 12:42:24 martin Exp $ */
22
/* $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $ */
33

44
/*-
@@ -25,7 +25,7 @@
2525
*/
2626

2727
#include <sys/cdefs.h>
28-
__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.105.4.3 2025/07/30 10:54:30 martin Exp $");
28+
__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.105.4.4 2025/09/23 12:42:24 martin Exp $");
2929

3030
#ifdef _KERNEL_OPT
3131
#include "opt_inet.h"
@@ -753,6 +753,7 @@ urtwn_alloc_rx_list(struct urtwn_softc *sc)
753753
data = &sc->rx_data[j][i];
754754

755755
data->sc = sc; /* Backpointer for callbacks. */
756+
data->pidx = j;
756757

757758
error = usbd_create_xfer(sc->rx_pipe[j], URTWN_RXBUFSZ,
758759
0, 0, &data->xfer);
@@ -2546,7 +2547,7 @@ urtwn_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status status)
25462547
size_t pidx = data->pidx;
25472548
uint32_t rxdw0;
25482549
uint8_t *buf;
2549-
int len, totlen, pktlen, infosz, npkts;
2550+
int len, totlen, pktlen, infosz, npkts, pktspacing;
25502551

25512552
URTWNHIST_FUNC(); URTWNHIST_CALLED();
25522553
DPRINTFN(DBG_RX, "status=%jd", status, 0, 0, 0);
@@ -2583,8 +2584,13 @@ urtwn_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status status)
25832584
if (npkts != 0)
25842585
rnd_add_uint32(&sc->rnd_source, npkts);
25852586

2587+
if (ISSET(sc->chip, URTWN_CHIP_92EU))
2588+
pktspacing = 8;
2589+
else
2590+
pktspacing = 128;
2591+
25862592
/* Process all of them. */
2587-
while (npkts-- > 0) {
2593+
while (npkts-- > 0 && len > 0) {
25882594
if (__predict_false(len < (int)sizeof(*stat))) {
25892595
DPRINTFN(DBG_RX, "len(%jd) is short than header",
25902596
len, 0, 0, 0);
@@ -2612,8 +2618,7 @@ urtwn_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status status)
26122618
/* Process 802.11 frame. */
26132619
urtwn_rx_frame(sc, buf, pktlen);
26142620

2615-
/* Next chunk is 128-byte aligned. */
2616-
totlen = roundup2(totlen, 128);
2621+
totlen = roundup2(totlen, pktspacing);
26172622
buf += totlen;
26182623
len -= totlen;
26192624
}
@@ -2994,6 +2999,7 @@ urtwn_start(struct ifnet *ifp)
29942999
device_printf(sc->sc_dev,
29953000
"unable to transmit packet\n");
29963001
if_statinc(ifp, if_oerrors);
3002+
urtwn_put_tx_data(sc, data);
29973003
continue;
29983004
}
29993005
m_freem(m);
@@ -3359,7 +3365,7 @@ urtwn_llt_init(struct urtwn_softc *sc)
33593365
if (sc->chip & URTWN_CHIP_88E)
33603366
pktbuf_count = R88E_TXPKTBUF_COUNT;
33613367
else if (sc->chip & URTWN_CHIP_92EU)
3362-
pktbuf_count = R88E_TXPKTBUF_COUNT;
3368+
pktbuf_count = R92E_TXPKTBUF_COUNT;
33633369
else
33643370
pktbuf_count = R92C_TXPKTBUF_COUNT;
33653371

0 commit comments

Comments
 (0)