Fix rx_bufs accounting buglet; reported on bugs@ by dns at strangeloop dot cc;
authormiod <miod@openbsd.org>
Wed, 28 Feb 2024 12:53:31 +0000 (12:53 +0000)
committermiod <miod@openbsd.org>
Wed, 28 Feb 2024 12:53:31 +0000 (12:53 +0000)
ok claudio@ deraadt@

sys/dev/ic/fxp.c

index d2001c0..02097de 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: fxp.c,v 1.133 2023/11/10 15:51:20 bluhm Exp $ */
+/*     $OpenBSD: fxp.c,v 1.134 2024/02/28 12:53:31 miod Exp $  */
 /*     $NetBSD: if_fxp.c,v 1.2 1997/06/05 02:01:55 thorpej Exp $       */
 
 /*
@@ -1382,11 +1382,12 @@ fxp_init(void *xsc)
        else
                bufs = FXP_NRFABUFS_MIN;
        if (sc->rx_bufs > bufs) {
-               while (sc->rfa_headm != NULL && sc->rx_bufs-- > bufs) {
+               while (sc->rfa_headm != NULL && sc->rx_bufs > bufs) {
                        rxmap = *((bus_dmamap_t *)sc->rfa_headm->m_ext.ext_buf);
                        bus_dmamap_unload(sc->sc_dmat, rxmap);
                        FXP_RXMAP_PUT(sc, rxmap);
                        sc->rfa_headm = m_free(sc->rfa_headm);
+                       sc->rx_bufs--;
                }
        } else if (sc->rx_bufs < bufs) {
                int err, tmp_rx_bufs = sc->rx_bufs;