net/iavf: fix core dump when exiting testpmd

Message ID 20231026085444.497296-1-kaiwenx.deng@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series net/iavf: fix core dump when exiting testpmd |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Kaiwen Deng Oct. 26, 2023, 8:54 a.m. UTC
  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@intel.com>
---
 drivers/net/iavf/iavf_rxtx_vec_common.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
  

Comments

Qi Zhang Oct. 31, 2023, 8:15 a.m. UTC | #1
> -----Original Message-----
> From: Kaiwen Deng <kaiwenx.deng@intel.com>
> Sent: Thursday, October 26, 2023 4:55 PM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Zhou, YidingX
> <yidingx.zhou@intel.com>; Deng, KaiwenX <kaiwenx.deng@intel.com>; Wu,
> Jingjing <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Lu,
> Wenzhuo <wenzhuo.lu@intel.com>; Richardson, Bruce
> <bruce.richardson@intel.com>
> Subject: [PATCH] net/iavf: fix core dump when exiting testpmd
> 
> 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@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;
> +		}

Could you explain how to reproduce this issue in the commit log.

Looks like it is to fix the scenario that queue stop and start again and some mbuf will be double free at some time?

> +
>  		if (++i == txq->nb_tx_desc)
>  			i = 0;
>  	}
> --
> 2.34.1
  

Patch

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;
 	}