[dpdk-dev] [PATCH 4/6] net/bnxt: fix a possible segfault in vector mode Tx path

Kalesh A P kalesh-anakkur.purayil at broadcom.com
Fri Aug 28 07:01:10 CEST 2020


From: Kalesh AP <kalesh-anakkur.purayil at broadcom.com>

rte_pktmbuf_prefree_seg() can return NULL if the mbuf still
has remaining references on it.

Adding a NULL check to prevent segfault.

Fixes: bc4a000f2f53 ("net/bnxt: implement SSE vector mode")
Cc: stable at dpdk.org

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil at broadcom.com>
Reviewed-by: Lance Richardson <lance.richardson at broadcom.com>
Reviewed-by: Ajit Kumar Khaparde <ajit.khaparde at broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur at broadcom.com>
---
 drivers/net/bnxt/bnxt_rxtx_vec_neon.c | 2 ++
 drivers/net/bnxt/bnxt_rxtx_vec_sse.c  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_rxtx_vec_neon.c b/drivers/net/bnxt/bnxt_rxtx_vec_neon.c
index 488a0b4..bf76c2a 100644
--- a/drivers/net/bnxt/bnxt_rxtx_vec_neon.c
+++ b/drivers/net/bnxt/bnxt_rxtx_vec_neon.c
@@ -329,6 +329,8 @@ bnxt_tx_cmp_vec(struct bnxt_tx_queue *txq, int nr_pkts)
 		tx_buf = &txr->tx_buf_ring[cons];
 		cons = RING_NEXT(txr->tx_ring_struct, cons);
 		mbuf = rte_pktmbuf_prefree_seg(tx_buf->mbuf);
+		if (unlikely(mbuf == NULL))
+			continue;
 		tx_buf->mbuf = NULL;
 
 		if (blk && mbuf->pool != free[0]->pool) {
diff --git a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
index c4ca5cf..98220bc 100644
--- a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
+++ b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
@@ -334,6 +334,8 @@ bnxt_tx_cmp_vec(struct bnxt_tx_queue *txq, int nr_pkts)
 		tx_buf = &txr->tx_buf_ring[cons];
 		cons = RING_NEXT(txr->tx_ring_struct, cons);
 		mbuf = rte_pktmbuf_prefree_seg(tx_buf->mbuf);
+		if (unlikely(mbuf == NULL))
+			continue;
 		tx_buf->mbuf = NULL;
 
 		if (blk && mbuf->pool != free[0]->pool) {
-- 
2.10.1



More information about the dev mailing list