[3/5] net/i40e: fix dereference before NULL check in mbuf release
Checks
Commit Message
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
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
>
>
@@ -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.