[PATCH 04/13] raw/ntb: fix memory leaks

Raghavendra Ningoji raghavendra.ningoji at amd.com
Wed Nov 4 12:19:52 CET 2026


The memory window size array allocated by the vendor init at probe
time was never freed.
The peer memory window base array allocated at each device start was
only freed if the start failed, so it leaked on every stop/start cycle.

Free the peer memory window base array when stopping the device, and
the memory window size array when closing it (which also happens on
device removal and on probe failure).

Fixes: c39d1e082a4b ("raw/ntb: setup queues")
Cc: stable at dpdk.org

Signed-off-by: Raghavendra Ningoji <raghavendra.ningoji at amd.com>
---
 drivers/raw/ntb/ntb.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/raw/ntb/ntb.c b/drivers/raw/ntb/ntb.c
index e42af0b9c5..af3fcd832b 100644
--- a/drivers/raw/ntb/ntb.c
+++ b/drivers/raw/ntb/ntb.c
@@ -820,6 +820,8 @@ ntb_dev_start(struct rte_rawdev *dev)
 
 err_up:
 	rte_free(hw->peer_mw_base);
+	hw->peer_mw_base = NULL;
+	hw->peer_used_mws = 0;
 err_q_init:
 	for (i = 0; i < hw->queue_pairs; i++) {
 		ntb_rxq_release_mbufs(hw->rx_queues[i]);
@@ -872,6 +874,10 @@ ntb_dev_stop(struct rte_rawdev *dev)
 		ntb_txq_release_mbufs(hw->tx_queues[i]);
 	}
 
+	rte_free(hw->peer_mw_base);
+	hw->peer_mw_base = NULL;
+	hw->peer_used_mws = 0;
+
 	dev->started = 0;
 }
 
@@ -890,6 +896,9 @@ ntb_dev_close(struct rte_rawdev *dev)
 		ntb_queue_release(dev, i);
 	hw->queue_pairs = 0;
 
+	rte_free(hw->mw_size);
+	hw->mw_size = NULL;
+
 	intr_handle = hw->pci_dev->intr_handle;
 	/* Disable interrupt only once */
 	if (!rte_intr_nb_efd_get(intr_handle) &&
-- 
2.34.1



More information about the stable mailing list