Hi,

I'm currently doing some busdma work, and possibly stepped over some driver bugs. When "bus_dmamap_load_mbuf_sg()" returns ENOMEM the mbuf chain is not freed. Is there some magic in "bus_dmamap_load_mbuf_sg()" for that error code or is there a possible memory leak in all E1000 drivers? See attached patch.

Index: if_em.c
===================================================================
--- if_em.c     (revision 284591)
+++ if_em.c     (working copy)
@@ -2027,9 +2027,6 @@
                /* Try it again, but only once */
                remap = 0;
                goto retry;
-       } else if (error == ENOMEM) {
-               adapter->no_tx_dma_setup++;
-               return (error);
        } else if (error != 0) {
                adapter->no_tx_dma_setup++;
                m_freem(*m_headp);
Index: if_igb.c
===================================================================
--- if_igb.c    (revision 284591)
+++ if_igb.c    (working copy)
@@ -1905,9 +1905,6 @@
                                goto retry;
                        } else
                                return (error);
-               case ENOMEM:
-                       txr->no_tx_dma_setup++;
-                       return (error);
                default:
                        txr->no_tx_dma_setup++;
                        m_freem(*m_headp);
Index: if_lem.c
===================================================================
--- if_lem.c    (revision 284591)
+++ if_lem.c    (working copy)
@@ -1693,6 +1693,8 @@
                }
        } else if (error != 0) {
                adapter->no_tx_dma_setup++;
+               m_freem(*m_headp);
+               *m_headp = NULL;
                return (error);
        }


--HPS
Index: if_em.c
===================================================================
--- if_em.c	(revision 284591)
+++ if_em.c	(working copy)
@@ -2027,9 +2027,6 @@
 		/* Try it again, but only once */
 		remap = 0;
 		goto retry;
-	} else if (error == ENOMEM) {
-		adapter->no_tx_dma_setup++;
-		return (error);
 	} else if (error != 0) {
 		adapter->no_tx_dma_setup++;
 		m_freem(*m_headp);
Index: if_igb.c
===================================================================
--- if_igb.c	(revision 284591)
+++ if_igb.c	(working copy)
@@ -1905,9 +1905,6 @@
 				goto retry;
 			} else
 				return (error);
-		case ENOMEM:
-			txr->no_tx_dma_setup++;
-			return (error);
 		default:
 			txr->no_tx_dma_setup++;
 			m_freem(*m_headp);
Index: if_lem.c
===================================================================
--- if_lem.c	(revision 284591)
+++ if_lem.c	(working copy)
@@ -1693,6 +1693,8 @@
 		}
 	} else if (error != 0) {
 		adapter->no_tx_dma_setup++;
+		m_freem(*m_headp);
+		*m_headp = NULL;
 		return (error);
 	}
 
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to