From e92247f03bc74802c5df9d9b6499dec7b19785e0 Mon Sep 17 00:00:00 2001 From: Ajit Khaparde Date: Wed, 13 Nov 2019 13:59:45 +0530 Subject: [PATCH] net/bnxt: fix null dereference in Rx stop Null-checking "rxq" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. Refactored the code to address this issue. Coverity issue: 350594 Fixes: fc4bfea59696 ("net/bnxt: fix Rx queue start/stop for Thor based NICs") Cc: stable@dpdk.org Signed-off-by: Ajit Khaparde Reviewed-by: Somnath Kotur --- drivers/net/bnxt/bnxt_rxq.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c index 7db72542ed..457ebede0e 100644 --- a/drivers/net/bnxt/bnxt_rxq.c +++ b/drivers/net/bnxt/bnxt_rxq.c @@ -516,13 +516,18 @@ int bnxt_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) } rxq = bp->rx_queues[rx_queue_id]; - vnic = rxq->vnic; - - if (!rxq || !vnic) { + if (!rxq) { PMD_DRV_LOG(ERR, "Invalid Rx queue %d\n", rx_queue_id); return -EINVAL; } + vnic = rxq->vnic; + if (!vnic) { + PMD_DRV_LOG(ERR, "VNIC not initialized for RxQ %d\n", + rx_queue_id); + return -EINVAL; + } + dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED; rxq->rx_started = false; PMD_DRV_LOG(DEBUG, "Rx queue stopped\n"); -- 2.20.1