[11/25] net/bnxt: fix crash in VF rep queue selection
diff mbox series

Message ID 20200911015603.88359-12-ajit.khaparde@broadcom.com
State Superseded
Delegated to: Ajit Khaparde
Headers show
Series
  • patchset for bnxt
Related show

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Ajit Khaparde Sept. 11, 2020, 1:55 a.m. UTC
From: Somnath Kotur <somnath.kotur@broadcom.com>

Instead of bounds checking against max possible rings while selecting
queue index for the VF rep, do it against the configured number of rings.

Fixes: 6dc83230b43b ("net/bnxt: support port representor data path")

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
---
 drivers/net/bnxt/bnxt_reps.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c
index 9f535c0ce..6fa867a8a 100644
--- a/drivers/net/bnxt/bnxt_reps.c
+++ b/drivers/net/bnxt/bnxt_reps.c
@@ -45,9 +45,12 @@  bnxt_vfr_recv(uint16_t port_id, uint16_t queue_id, struct rte_mbuf *mbuf)
 
 	vfr_eth_dev = &rte_eth_devices[port_id];
 	vfr_bp = vfr_eth_dev->data->dev_private;
-	/* If rxq_id happens to be > max rep_queue, use rxq0 */
-	que = queue_id < BNXT_MAX_VF_REP_RINGS ? queue_id : 0;
+	/* 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];
+	/* Ideally should not happen now, paranoid check */
+	if (!rep_rxq)
+		return 1;
 	rep_rxr = rep_rxq->rx_ring;
 	mask = rep_rxr->rx_ring_struct->ring_mask;