Author: erj
Date: Thu Jan  2 22:44:38 2020
New Revision: 356298
URL: https://svnweb.freebsd.org/changeset/base/356298

Log:
  MFC r354207: iflib: cleanup memory leaks on driver detach
  
  Sponsored by: Intel Corporation

Modified:
  stable/12/sys/net/iflib.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/net/iflib.c
==============================================================================
--- stable/12/sys/net/iflib.c   Thu Jan  2 22:42:18 2020        (r356297)
+++ stable/12/sys/net/iflib.c   Thu Jan  2 22:44:38 2020        (r356298)
@@ -1764,6 +1764,14 @@ iflib_txq_destroy(iflib_txq_t txq)
 
        for (int i = 0; i < txq->ift_size; i++)
                iflib_txsd_destroy(ctx, txq, i);
+
+       if (txq->ift_br != NULL) {
+               ifmp_ring_free(txq->ift_br);
+               txq->ift_br = NULL;
+       }
+
+       mtx_destroy(&txq->ift_mtx);
+
        if (txq->ift_sds.ifsd_map != NULL) {
                free(txq->ift_sds.ifsd_map, M_IFLIB);
                txq->ift_sds.ifsd_map = NULL;
@@ -1784,6 +1792,9 @@ iflib_txq_destroy(iflib_txq_t txq)
                bus_dma_tag_destroy(txq->ift_tso_buf_tag);
                txq->ift_tso_buf_tag = NULL;
        }
+       if (txq->ift_ifdi != NULL) {
+               free(txq->ift_ifdi, M_IFLIB);
+       }
 }
 
 static void
@@ -2263,6 +2274,8 @@ iflib_rx_sds_free(iflib_rxq_t rxq)
                }
                free(rxq->ifr_fl, M_IFLIB);
                rxq->ifr_fl = NULL;
+               free(rxq->ifr_ifdi, M_IFLIB);
+               rxq->ifr_ifdi = NULL;
                rxq->ifr_cq_cidx = 0;
        }
 }
@@ -5599,9 +5612,9 @@ iflib_tx_structures_free(if_ctx_t ctx)
        int i, j;
 
        for (i = 0; i < NTXQSETS(ctx); i++, txq++) {
-               iflib_txq_destroy(txq);
                for (j = 0; j < sctx->isc_ntxqs; j++)
                        iflib_dma_free(&txq->ift_ifdi[j]);
+               iflib_txq_destroy(txq);
        }
        free(ctx->ifc_txqs, M_IFLIB);
        ctx->ifc_txqs = NULL;
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to