svn commit: r354207 - head/sys/net
Eric Joyner
erj at FreeBSD.org
Wed Oct 30 20:45:13 UTC 2019
Author: erj
Date: Wed Oct 30 20:45:12 2019
New Revision: 354207
URL: https://svnweb.freebsd.org/changeset/base/354207
Log:
iflib: cleanup memory leaks on driver detach
From Jake:
The iflib stack failed to release all of the memory allocated under
M_IFLIB during device detach.
Specifically, the ifmp_ring, the ift_ifdi Tx DMA info, and the ifr_ifdi Rx
DMA info were not being released.
Release this memory so that iflib won't leak memory when a device
detaches.
Since we're freeing the ift_ifdi pointer during iflib_txq_destroy we
need to call this only after iflib_dma_free in iflib_tx_structures_free.
Additionally, also ensure that we destroy the callout mutex associated
with each Tx queue when we free it.
Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
Submitted by: Jacob Keller <jacob.e.keller at intel.com>
Reviewed by: erj@, gallatin@
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D22157
Modified:
head/sys/net/iflib.c
Modified: head/sys/net/iflib.c
==============================================================================
--- head/sys/net/iflib.c Wed Oct 30 20:43:27 2019 (r354206)
+++ head/sys/net/iflib.c Wed Oct 30 20:45:12 2019 (r354207)
@@ -1725,6 +1725,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;
@@ -1745,6 +1753,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
@@ -2225,6 +2236,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;
}
}
@@ -5658,9 +5671,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;
More information about the svn-src-head
mailing list