diff mbox series

[18/18] net/bnxt: check VF rep pointer before access

Message ID 20220104083824.23001-19-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/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
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>

The PF or trusted VF Rx handler could invoke the VF representor's
Rx function without knowledge of the application cleaning up the
representor ports. Check if the vfr_bp pointer is valid before
accessing it.

Fixes: 6dc83230b43b ("net/bnxt: support port representor data path")
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_reps.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c
index f24f5ef..5e140f0 100644
--- a/drivers/net/bnxt/bnxt_reps.c
+++ b/drivers/net/bnxt/bnxt_reps.c
@@ -35,16 +35,20 @@  static const struct eth_dev_ops bnxt_rep_dev_ops = {
 uint16_t
 bnxt_vfr_recv(uint16_t port_id, uint16_t queue_id, struct rte_mbuf *mbuf)
 {
-	struct rte_mbuf **prod_rx_buf;
+	struct bnxt_representor *vfr_bp = NULL;
 	struct bnxt_rx_ring_info *rep_rxr;
-	struct bnxt_rx_queue *rep_rxq;
 	struct rte_eth_dev *vfr_eth_dev;
-	struct bnxt_representor *vfr_bp;
+	struct rte_mbuf **prod_rx_buf;
+	struct bnxt_rx_queue *rep_rxq;
 	uint16_t mask;
 	uint8_t que;
 
 	vfr_eth_dev = &rte_eth_devices[port_id];
-	vfr_bp = vfr_eth_dev->data->dev_private;
+	vfr_bp = vfr_eth_dev ? vfr_eth_dev->data->dev_private : NULL;
+
+	if (unlikely(vfr_bp == NULL))
+		return 1;
+
 	/* If rxq_id happens to be > nr_rings, use ring 0 */
 	que = queue_id < vfr_bp->rx_nr_rings ? queue_id : 0;
 	rep_rxq = vfr_bp->rx_queues[que];