[3/5] net/i40e: fix dereference before NULL check in mbuf release

Message ID 20190405134511.49066-4-bruce.richardson@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series some small fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Bruce Richardson April 5, 2019, 1:45 p.m. UTC
  Coverity flags that the txq variable is used before it's checked for NULL.

Coverity issue: 195023

Fixes: 24853544c84c ("net/i40e: fix mbuf free in vector Tx")
Cc: qi.z.zhang@intel.com
CC: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/i40e/i40e_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Rami Rosen April 5, 2019, 2:08 p.m. UTC | #1
Acked-By: Rami Rosen <ramirose@gmail.com>

In this occasion I noticed that there is a typo in the code that appears in
the patch;
it should be "Pointer to txq" instead of "Pointer to rxq":
I would consider resending and fixing it on this occasion:

>  if (!txq || !txq->sw_ring) {
>               PMD_DRV_LOG(DEBUG, "Pointer to rxq or sw_ring is NULL");
>                return;
>        }






‏<bruce.richardson@intel.com>:

> Coverity flags that the txq variable is used before it's checked for NULL.
>
> Coverity issue: 195023
>
> Fixes: 24853544c84c ("net/i40e: fix mbuf free in vector Tx")
> Cc: qi.z.zhang@intel.com
> CC: stable@dpdk.org
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  drivers/net/i40e/i40e_rxtx.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
> index 8f727fae6..5ce85eb52 100644
> --- a/drivers/net/i40e/i40e_rxtx.c
> +++ b/drivers/net/i40e/i40e_rxtx.c
> @@ -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");
>                 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.
> --
> 2.20.1
>
>
  

Patch

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 8f727fae6..5ce85eb52 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -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");
 		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.