net/iavf: fix access to null value

Message ID 20240124020555.3336924-1-mingjinx.ye@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Bruce Richardson
Headers
Series net/iavf: fix access to null value |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Mingjin Ye Jan. 24, 2024, 2:05 a.m. UTC
  The "vsi" may be null, so it needs to be used after checking.

Fixes: ab28aad9c24f ("net/iavf: fix Rx Tx burst in multi-process")
Cc: stable@dpdk.org

Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com>
---
 drivers/net/iavf/iavf_rxtx.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
  

Comments

Bruce Richardson Feb. 2, 2024, 10:47 a.m. UTC | #1
On Wed, Jan 24, 2024 at 02:05:55AM +0000, Mingjin Ye wrote:
> The "vsi" may be null, so it needs to be used after checking.
> 
> Fixes: ab28aad9c24f ("net/iavf: fix Rx Tx burst in multi-process")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com>
> ---
>  drivers/net/iavf/iavf_rxtx.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
This looks safer with the checks this way.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  
Anatoly Burakov Feb. 9, 2024, 2:27 p.m. UTC | #2
On 1/24/2024 3:05 AM, Mingjin Ye wrote:
> The "vsi" may be null, so it needs to be used after checking.
> 
> Fixes: ab28aad9c24f ("net/iavf: fix Rx Tx burst in multi-process")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com>
> ---
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
  
Bruce Richardson Feb. 29, 2024, 3:29 p.m. UTC | #3
On Fri, Feb 09, 2024 at 03:27:56PM +0100, Burakov, Anatoly wrote:
> On 1/24/2024 3:05 AM, Mingjin Ye wrote:
> > The "vsi" may be null, so it needs to be used after checking.
> > 
> > Fixes: ab28aad9c24f ("net/iavf: fix Rx Tx burst in multi-process")

Fixes: 9f6186cf0d80 ("net/iavf: fix Rx/Tx burst in multi-process")

> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com>
> > ---
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
>
Applied to dpdk-next-net-intel.

Thanks,
/Bruce
  

Patch

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 5ba4527ae3..8992e728cd 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -3781,12 +3781,13 @@  iavf_recv_pkts_no_poll(void *rx_queue, struct rte_mbuf **rx_pkts,
 				uint16_t nb_pkts)
 {
 	struct iavf_rx_queue *rxq = rx_queue;
-	enum iavf_rx_burst_type rx_burst_type =
-		rxq->vsi->adapter->rx_burst_type;
+	enum iavf_rx_burst_type rx_burst_type;
 
 	if (!rxq->vsi || rxq->vsi->adapter->no_poll)
 		return 0;
 
+	rx_burst_type = rxq->vsi->adapter->rx_burst_type;
+
 	return iavf_rx_pkt_burst_ops[rx_burst_type](rx_queue,
 								rx_pkts, nb_pkts);
 }
@@ -3796,12 +3797,13 @@  iavf_xmit_pkts_no_poll(void *tx_queue, struct rte_mbuf **tx_pkts,
 				uint16_t nb_pkts)
 {
 	struct iavf_tx_queue *txq = tx_queue;
-	enum iavf_tx_burst_type tx_burst_type =
-		txq->vsi->adapter->tx_burst_type;
+	enum iavf_tx_burst_type tx_burst_type;
 
 	if (!txq->vsi || txq->vsi->adapter->no_poll)
 		return 0;
 
+	tx_burst_type = txq->vsi->adapter->tx_burst_type;
+
 	return iavf_tx_pkt_burst_ops[tx_burst_type](tx_queue,
 								tx_pkts, nb_pkts);
 }