aboutsummaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorEric Joyner <erj@FreeBSD.org>2019-10-30 20:45:12 +0000
committerEric Joyner <erj@FreeBSD.org>2019-10-30 20:45:12 +0000
commit244e7cffa51a2c8ad972bcdd4a9ce972e7bb6514 (patch)
tree6432cee01be546f90616d24d505adc54b9108b7a /sys/net
parentef546520da8132eb7a66602ca001032cfab0eaee (diff)
downloadsrc-244e7cffa51a2c8ad972bcdd4a9ce972e7bb6514.tar.gz
src-244e7cffa51a2c8ad972bcdd4a9ce972e7bb6514.zip
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@intel.com> Submitted by: Jacob Keller <jacob.e.keller@intel.com> Reviewed by: erj@, gallatin@ MFC after: 1 week Sponsored by: Intel Corporation Differential Revision: https://reviews.freebsd.org/D22157
Notes
Notes: svn path=/head/; revision=354207
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/iflib.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index 90747ef1aa78..e88c76f23622 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -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;