net/bnxt: fix null dereference in Rx stop
authorAjit Khaparde <ajit.khaparde@broadcom.com>
Wed, 13 Nov 2019 08:29:45 +0000 (13:59 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 20 Nov 2019 16:36:05 +0000 (17:36 +0100)
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 <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
drivers/net/bnxt/bnxt_rxq.c

index 7db7254..457ebed 100644 (file)
@@ -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");