net/i40e: fix dereference before null check in mbuf release
authorBruce Richardson <bruce.richardson@intel.com>
Mon, 8 Apr 2019 09:46:38 +0000 (10:46 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 22 Apr 2019 22:15:10 +0000 (00:15 +0200)
Coverity flags that the txq variable is used before it's checked for NULL.
Also fix typo in error message.

Coverity issue: 195023
Fixes: 24853544c84c ("net/i40e: fix mbuf free in vector Tx")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Rami Rosen <ramirose@gmail.com>
drivers/net/i40e/i40e_rxtx.c

index 58ed814..1489552 100644 (file)
@@ -2423,13 +2423,13 @@ i40e_tx_queue_release_mbufs(struct i40e_tx_queue *txq)
        struct rte_eth_dev *dev;
        uint16_t i;
 
-       dev = &rte_eth_devices[txq->port_id];
-
        if (!txq || !txq->sw_ring) {
-               PMD_DRV_LOG(DEBUG, "Pointer to rxq or sw_ring is NULL");
+               PMD_DRV_LOG(DEBUG, "Pointer to txq or sw_ring is NULL");
                return;
        }
 
+       dev = &rte_eth_devices[txq->port_id];
+
        /**
         *  vPMD tx will not set sw_ring's mbuf to NULL after free,
         *  so need to free remains more carefully.