[PATCH] net/iavf: fix core dump when exiting testpmd

Kaiwen Deng kaiwenx.deng at intel.com
Thu Oct 26 10:54:44 CEST 2023


release null mbuf results coredump.
This commit adding mbuf check before releasing.

Fixes: 12016895fcf3 ("net/iavf: fix buffer leak on Tx queue stop")

Signed-off-by: Kaiwen Deng <kaiwenx.deng at intel.com>
---
 drivers/net/iavf/iavf_rxtx_vec_common.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/iavf/iavf_rxtx_vec_common.h b/drivers/net/iavf/iavf_rxtx_vec_common.h
index e18cdc3f11..f50a500536 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_common.h
+++ b/drivers/net/iavf/iavf_rxtx_vec_common.h
@@ -187,8 +187,11 @@ _iavf_tx_queue_release_mbufs_vec(struct iavf_tx_queue *txq)
 
 	i = txq->next_dd - txq->rs_thresh + 1;
 	while (i != txq->tx_tail) {
-		rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf);
-		txq->sw_ring[i].mbuf = NULL;
+		if (txq->sw_ring[i].mbuf) {
+			rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf);
+			txq->sw_ring[i].mbuf = NULL;
+		}
+
 		if (++i == txq->nb_tx_desc)
 			i = 0;
 	}
-- 
2.34.1



More information about the dev mailing list