patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Jiawen Wu <jiawenwu@trustnetic.com>
To: dev@dpdk.org
Cc: Jiawen Wu <jiawenwu@trustnetic.com>, stable@dpdk.org
Subject: [PATCH 15/19] net/ngbe: fix memory leak
Date: Tue, 18 Jun 2024 15:11:46 +0800	[thread overview]
Message-ID: <20240618071150.21564-16-jiawenwu@trustnetic.com> (raw)
In-Reply-To: <20240618071150.21564-1-jiawenwu@trustnetic.com>

Fix some memory leaks caused by not release resource in time.

Fixes: 43b7e5ea60ac ("net/ngbe: support Rx queue setup/release")
Fixes: a58e7c312c6b ("net/ngbe: support Tx queue setup/release")
Cc: stable@dpdk.org

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/ngbe/ngbe_rxtx.c | 8 ++++++++
 drivers/net/ngbe/ngbe_rxtx.h | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/drivers/net/ngbe/ngbe_rxtx.c b/drivers/net/ngbe/ngbe_rxtx.c
index c54c67f7ee..507bd3d526 100644
--- a/drivers/net/ngbe/ngbe_rxtx.c
+++ b/drivers/net/ngbe/ngbe_rxtx.c
@@ -1813,6 +1813,7 @@ ngbe_tx_queue_release(struct ngbe_tx_queue *txq)
 		if (txq->ops != NULL) {
 			txq->ops->release_mbufs(txq);
 			txq->ops->free_swring(txq);
+			rte_memzone_free(txq->mz);
 		}
 		rte_free(txq);
 	}
@@ -2030,6 +2031,7 @@ ngbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	txq->mz = tz;
 	txq->nb_tx_desc = nb_desc;
 	txq->tx_free_thresh = tx_free_thresh;
 	txq->pthresh = tx_conf->tx_thresh.pthresh;
@@ -2138,6 +2140,7 @@ ngbe_rx_queue_release(struct ngbe_rx_queue *rxq)
 		ngbe_rx_queue_release_mbufs(rxq);
 		rte_free(rxq->sw_ring);
 		rte_free(rxq->sw_sc_ring);
+		rte_memzone_free(rxq->mz);
 		rte_free(rxq);
 	}
 }
@@ -2228,6 +2231,10 @@ ngbe_reset_rx_queue(struct ngbe_adapter *adapter, struct ngbe_rx_queue *rxq)
 	rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
 	rxq->rx_tail = 0;
 	rxq->nb_rx_hold = 0;
+
+	if (rxq->pkt_first_seg != NULL)
+		rte_pktmbuf_free(rxq->pkt_first_seg);
+
 	rxq->pkt_first_seg = NULL;
 	rxq->pkt_last_seg = NULL;
 
@@ -2323,6 +2330,7 @@ ngbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
 		return -ENOMEM;
 	}
 
+	rxq->mz = rz;
 	/*
 	 * Zero init all the descriptors in the ring.
 	 */
diff --git a/drivers/net/ngbe/ngbe_rxtx.h b/drivers/net/ngbe/ngbe_rxtx.h
index 41580ba0b9..7574db32d8 100644
--- a/drivers/net/ngbe/ngbe_rxtx.h
+++ b/drivers/net/ngbe/ngbe_rxtx.h
@@ -291,6 +291,7 @@ struct ngbe_rx_queue {
 	struct rte_mbuf fake_mbuf;
 	/** hold packets to return to application */
 	struct rte_mbuf *rx_stage[RTE_PMD_NGBE_RX_MAX_BURST * 2];
+	const struct rte_memzone *mz;
 };
 
 /**
@@ -373,6 +374,7 @@ struct ngbe_tx_queue {
 	uint8_t              tx_deferred_start; /**< not in global dev start */
 
 	const struct ngbe_txq_ops *ops;       /**< txq ops */
+	const struct rte_memzone *mz;
 };
 
 struct ngbe_txq_ops {
-- 
2.27.0


  parent reply	other threads:[~2024-06-18  7:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240618071150.21564-1-jiawenwu@trustnetic.com>
2024-06-18  7:11 ` [PATCH 01/19] net/txgbe: fix to parse tunnel packets Jiawen Wu
2024-06-18  7:11 ` [PATCH 02/19] net/txgbe: fix flow filters in VT mode Jiawen Wu
2024-06-18  7:11 ` [PATCH 03/19] net/txgbe: fix Tx hang on queue disable Jiawen Wu
2024-06-18  7:11 ` [PATCH 04/19] net/txgbe: restrict the configuration of VLAN strip offload Jiawen Wu
2024-06-18  7:11 ` [PATCH 05/19] net/txgbe: reconfigure more MAC Rx registers Jiawen Wu
2024-06-18  7:11 ` [PATCH 06/19] net/txgbe: fix VF promiscuous and allmulticast Jiawen Wu
2024-06-18  7:11 ` [PATCH 07/19] net/ngbe: special config for YT8531SH-CA PHY Jiawen Wu
2024-06-18  7:11 ` [PATCH 08/19] net/ngbe: keep PHY power down while device probing Jiawen Wu
2024-06-18  7:11 ` [PATCH 10/19] net/txgbe: fix hotplug remove Jiawen Wu
2024-06-18  7:11 ` [PATCH 11/19] net/ngbe: " Jiawen Wu
2024-06-18  7:11 ` [PATCH 12/19] net/txgbe: correct valid MTU range Jiawen Wu
2024-06-18  7:11 ` [PATCH 13/19] net/ngbe: " Jiawen Wu
2024-06-18  7:11 ` [PATCH 14/19] net/txgbe: fix memory leak Jiawen Wu
2024-06-18  7:11 ` Jiawen Wu [this message]
2024-06-18  7:11 ` [PATCH 16/19] net/txgbe: fix Rx interrupt Jiawen Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240618071150.21564-16-jiawenwu@trustnetic.com \
    --to=jiawenwu@trustnetic.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).