Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Fix a problem with the ALTQ changes that can cause b...



details:   https://anonhg.NetBSD.org/src/rev/64c4eb14ef7f
branches:  trunk
changeset: 500819:64c4eb14ef7f
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Dec 19 00:06:01 2000 +0000

description:
Fix a problem with the ALTQ changes that can cause bogus memory
refernces.  Problem reported by Luke Mewburn.

diffstat:

 sys/dev/ic/i82557.c    |  11 +++++++----
 sys/dev/ic/rtl81x9.c   |  11 +++++++----
 sys/dev/ic/smc83c170.c |  11 +++++++----
 sys/dev/ic/tulip.c     |  13 +++++++++----
 sys/dev/pci/if_sip.c   |  18 +++++++++++-------
 sys/dev/pci/if_vr.c    |  11 +++++++----
 6 files changed, 48 insertions(+), 27 deletions(-)

diffs (263 lines):

diff -r 303e29d7dab3 -r 64c4eb14ef7f sys/dev/ic/i82557.c
--- a/sys/dev/ic/i82557.c       Mon Dec 18 23:57:13 2000 +0000
+++ b/sys/dev/ic/i82557.c       Tue Dec 19 00:06:01 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i82557.c,v 1.43 2000/12/14 06:27:25 thorpej Exp $      */
+/*     $NetBSD: i82557.c,v 1.44 2000/12/19 00:06:01 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
@@ -734,6 +734,7 @@
                IFQ_POLL(&ifp->if_snd, m0);
                if (m0 == NULL)
                        break;
+               m = NULL;
 
                /*
                 * Get the next available transmit descriptor.
@@ -769,10 +770,8 @@
                        }
                        m_copydata(m0, 0, m0->m_pkthdr.len, mtod(m, caddr_t));
                        m->m_pkthdr.len = m->m_len = m0->m_pkthdr.len;
-                       m_freem(m0);
-                       m0 = m;
                        error = bus_dmamap_load_mbuf(sc->sc_dmat, dmamap,
-                           m0, BUS_DMA_NOWAIT);
+                           m, BUS_DMA_NOWAIT);
                        if (error) {
                                printf("%s: unable to load Tx buffer, "
                                    "error = %d\n", sc->sc_dev.dv_xname, error);
@@ -781,6 +780,10 @@
                }
 
                IFQ_DEQUEUE(&ifp->if_snd, m0);
+               if (m != NULL) {
+                       m_freem(m0);
+                       m0 = m;
+               }
 
                /* Initialize the fraglist. */
                for (seg = 0; seg < dmamap->dm_nsegs; seg++) {
diff -r 303e29d7dab3 -r 64c4eb14ef7f sys/dev/ic/rtl81x9.c
--- a/sys/dev/ic/rtl81x9.c      Mon Dec 18 23:57:13 2000 +0000
+++ b/sys/dev/ic/rtl81x9.c      Tue Dec 19 00:06:01 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtl81x9.c,v 1.25 2000/12/14 06:27:26 thorpej Exp $     */
+/*     $NetBSD: rtl81x9.c,v 1.26 2000/12/19 00:06:01 thorpej Exp $     */
 
 /*
  * Copyright (c) 1997, 1998
@@ -1255,6 +1255,7 @@
                IFQ_POLL(&ifp->if_snd, m_head);
                if (m_head == NULL)
                        break;
+               m_new = NULL;
 
                idx = sc->rtk_cdata.cur_tx;
 
@@ -1285,10 +1286,8 @@
                            mtod(m_new, caddr_t));
                        m_new->m_pkthdr.len = m_new->m_len =
                            m_head->m_pkthdr.len;
-                       m_freem(m_head);
-                       m_head = m_new;
                        error = bus_dmamap_load_mbuf(sc->sc_dmat,
-                           sc->snd_dmamap[idx], m_head, BUS_DMA_NOWAIT);
+                           sc->snd_dmamap[idx], m_new, BUS_DMA_NOWAIT);
                        if (error) {
                                printf("%s: unable to load Tx buffer, "
                                    "error = %d\n", sc->sc_dev.dv_xname, error);
@@ -1296,6 +1295,10 @@
                        }
                }
                IFQ_DEQUEUE(&ifp->if_snd, m_head);
+               if (m_new != NULL) {
+                       m_freem(m_head);
+                       m_head = m_new;
+               }
 
                RTK_CUR_TXMBUF(sc) = m_head;
 
diff -r 303e29d7dab3 -r 64c4eb14ef7f sys/dev/ic/smc83c170.c
--- a/sys/dev/ic/smc83c170.c    Mon Dec 18 23:57:13 2000 +0000
+++ b/sys/dev/ic/smc83c170.c    Tue Dec 19 00:06:01 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smc83c170.c,v 1.40 2000/12/14 06:27:26 thorpej Exp $   */
+/*     $NetBSD: smc83c170.c,v 1.41 2000/12/19 00:06:02 thorpej Exp $   */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -354,6 +354,7 @@
                IFQ_POLL(&ifp->if_snd, m0);
                if (m0 == NULL)
                        break;
+               m = NULL;
 
                /*
                 * Get the last and next available transmit descriptor.
@@ -389,10 +390,8 @@
                        }
                        m_copydata(m0, 0, m0->m_pkthdr.len, mtod(m, caddr_t));
                        m->m_pkthdr.len = m->m_len = m0->m_pkthdr.len;
-                       m_freem(m0);
-                       m0 = m;
                        error = bus_dmamap_load_mbuf(sc->sc_dmat, dmamap,
-                           m0, BUS_DMA_NOWAIT);
+                           m, BUS_DMA_NOWAIT);
                        if (error) {
                                printf("%s: unable to load Tx buffer, "
                                    "error = %d\n", sc->sc_dev.dv_xname, error);
@@ -400,6 +399,10 @@
                        }
                }
                IFQ_DEQUEUE(&ifp->if_snd, m0);
+               if (m != NULL) {
+                       m_freem(m0);
+                       m0 = m;
+               }
 
                /* Initialize the fraglist. */
                fr->ef_nfrags = dmamap->dm_nsegs;
diff -r 303e29d7dab3 -r 64c4eb14ef7f sys/dev/ic/tulip.c
--- a/sys/dev/ic/tulip.c        Mon Dec 18 23:57:13 2000 +0000
+++ b/sys/dev/ic/tulip.c        Tue Dec 19 00:06:01 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tulip.c,v 1.83 2000/12/14 06:27:26 thorpej Exp $       */
+/*     $NetBSD: tulip.c,v 1.84 2000/12/19 00:06:02 thorpej Exp $       */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -734,6 +734,7 @@
                IFQ_POLL(&ifp->if_snd, m0);
                if (m0 == NULL)
                        break;
+               m = NULL;
 
                dmamap = txs->txs_dmamap;
 
@@ -769,10 +770,8 @@
                        }
                        m_copydata(m0, 0, m0->m_pkthdr.len, mtod(m, caddr_t));
                        m->m_pkthdr.len = m->m_len = m0->m_pkthdr.len;
-                       m_freem(m0);
-                       m0 = m;
                        error = bus_dmamap_load_mbuf(sc->sc_dmat, dmamap,
-                           m0, BUS_DMA_NOWAIT);
+                           m, BUS_DMA_NOWAIT);
                        if (error) {
                                printf("%s: unable to load Tx buffer, "
                                    "error = %d\n", sc->sc_dev.dv_xname, error);
@@ -797,10 +796,16 @@
                         */
                        ifp->if_flags |= IFF_OACTIVE;
                        bus_dmamap_unload(sc->sc_dmat, dmamap);
+                       if (m != NULL)
+                               m_freem(m);
                        break;
                }
 
                IFQ_DEQUEUE(&ifp->if_snd, m0);
+               if (m != NULL) {
+                       m_freem(m0);
+                       m0 = m;
+               }
 
                /*
                 * WE ARE NOW COMMITTED TO TRANSMITTING THE PACKET.
diff -r 303e29d7dab3 -r 64c4eb14ef7f sys/dev/pci/if_sip.c
--- a/sys/dev/pci/if_sip.c      Mon Dec 18 23:57:13 2000 +0000
+++ b/sys/dev/pci/if_sip.c      Tue Dec 19 00:06:01 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_sip.c,v 1.21 2000/12/14 06:42:57 thorpej Exp $      */
+/*     $NetBSD: if_sip.c,v 1.22 2000/12/19 00:12:47 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1999 Network Computer, Inc.
@@ -685,6 +685,7 @@
                IFQ_POLL(&ifp->if_snd, m0);
                if (m0 == NULL)
                        break;
+               m = NULL;
 
                dmamap = txs->txs_dmamap;
 
@@ -713,10 +714,8 @@
                        }
                        m_copydata(m0, 0, m0->m_pkthdr.len, mtod(m, caddr_t));
                        m->m_pkthdr.len = m->m_len = m0->m_pkthdr.len;
-                       m_freem(m0);
-                       m0 = m;
                        error = bus_dmamap_load_mbuf(sc->sc_dmat, dmamap,
-                           m0, BUS_DMA_NOWAIT);
+                           m, BUS_DMA_NOWAIT);
                        if (error) {
                                printf("%s: unable to load Tx buffer, "
                                    "error = %d\n", sc->sc_dev.dv_xname, error);
@@ -724,8 +723,6 @@
                        }
                }
 
-               IFQ_DEQUEUE(&ifp->if_snd, m0);
-
                /*
                 * Ensure we have enough descriptors free to describe
                 * the packet.
@@ -743,10 +740,17 @@
                         */
                        ifp->if_flags |= IFF_OACTIVE;
                        bus_dmamap_unload(sc->sc_dmat, dmamap);
-                       IF_PREPEND(&ifp->if_snd, m0);
+                       if (m != NULL)
+                               m_freem(m);
                        break;
                }
 
+               IFQ_DEQUEUE(&ifp->if_snd, m0);
+               if (m != NULL) {
+                       m_freem(m0);
+                       m0 = m;
+               }
+
                /*
                 * WE ARE NOW COMMITTED TO TRANSMITTING THE PACKET.
                 */
diff -r 303e29d7dab3 -r 64c4eb14ef7f sys/dev/pci/if_vr.c
--- a/sys/dev/pci/if_vr.c       Mon Dec 18 23:57:13 2000 +0000
+++ b/sys/dev/pci/if_vr.c       Tue Dec 19 00:06:01 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_vr.c,v 1.42 2000/12/14 06:42:57 thorpej Exp $       */
+/*     $NetBSD: if_vr.c,v 1.43 2000/12/19 00:12:47 thorpej Exp $       */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -951,6 +951,7 @@
                IFQ_POLL(&ifp->if_snd, m0);
                if (m0 == NULL)
                        break;
+               m = NULL;
 
                /*
                 * Get the next available transmit descriptor.
@@ -984,10 +985,8 @@
                        }
                        m_copydata(m0, 0, m0->m_pkthdr.len, mtod(m, caddr_t));
                        m->m_pkthdr.len = m->m_len = m0->m_pkthdr.len;
-                       m_freem(m0);
-                       m0 = m;
                        error = bus_dmamap_load_mbuf(sc->vr_dmat,
-                           ds->ds_dmamap, m0, BUS_DMA_NOWAIT);
+                           ds->ds_dmamap, m, BUS_DMA_NOWAIT);
                        if (error) {
                                printf("%s: unable to load Tx buffer, "
                                    "error = %d\n", sc->vr_dev.dv_xname, error);
@@ -996,6 +995,10 @@
                }
 
                IFQ_DEQUEUE(&ifp->if_snd, m0);
+               if (m != NULL) {
+                       m_freem(m0);
+                       m0 = m;
+               }
 
                /* Sync the DMA map. */
                bus_dmamap_sync(sc->vr_dmat, ds->ds_dmamap, 0,



Home | Main Index | Thread Index | Old Index