diff mbox series

[16/18] net/bnxt: fix pointer access

Message ID 20220104083824.23001-17-kalesh-anakkur.purayil@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ajit Khaparde
Headers show
Series bnxt PMD fixes | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Kalesh A P Jan. 4, 2022, 8:38 a.m. UTC
From: Ajit Khaparde <ajit.khaparde@broadcom.com>

Validate the pointers in rxq before accessing them.
Otherwise it can cause a segfault.

Fixes: 657c2a7f1dd4 ("net/bnxt: create aggregation rings when needed")
Cc: stable@dpdk.org

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 drivers/net/bnxt/bnxt_rxq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
index 9f1d1d4..cd3bb14 100644
--- a/drivers/net/bnxt/bnxt_rxq.c
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -214,7 +214,9 @@  void bnxt_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq)
 		}
 	}
 	/* Free up mbufs in Agg ring */
-	if (!bnxt_need_agg_ring(rxq->bp->eth_dev))
+	if (rxq->bp == NULL ||
+	    rxq->bp->eth_dev == NULL ||
+	    !bnxt_need_agg_ring(rxq->bp->eth_dev))
 		return;
 
 	sw_ring = rxq->rx_ring->ag_buf_ring;