[v2] net/idpf: fix crash when launching l3fwd

Message ID 20221117101509.14472-1-beilei.xing@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series [v2] net/idpf: fix crash when launching l3fwd |

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-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Xing, Beilei Nov. 17, 2022, 10:15 a.m. UTC
  From: Beilei Xing <beilei.xing@intel.com>

There's core dump when launching l3fwd with 1 queue 1 core. It's
because NULL pointer is used if fail to configure device.
This patch removes incorrect check during device configuration,
and checks NULL pointer when executing VIRTCHNL2_OP_DEALLOC_VECTORS.

Fixes: 549343c25db8 ("net/idpf: support device initialization")
Fixes: 70675bcc3a57 ("net/idpf: support RSS")
Fixes: 37291a68fd78 ("net/idpf: support write back based on ITR expire")

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
v2 change: Fix typo.

 drivers/net/idpf/idpf_ethdev.c | 7 -------
 drivers/net/idpf/idpf_vchnl.c  | 3 +++
 2 files changed, 3 insertions(+), 7 deletions(-)
  

Comments

Jingjing Wu Nov. 18, 2022, 6:24 a.m. UTC | #1
> -
>  	if (conf->txmode.mq_mode != RTE_ETH_MQ_TX_NONE) {
>  		PMD_INIT_LOG(ERR, "Multi-queue TX mode %d is not supported",
>  			     conf->txmode.mq_mode);
> diff --git a/drivers/net/idpf/idpf_vchnl.c b/drivers/net/idpf/idpf_vchnl.c
> index ac6486d4ef..88770447f8 100644
> --- a/drivers/net/idpf/idpf_vchnl.c
> +++ b/drivers/net/idpf/idpf_vchnl.c
> @@ -1197,6 +1197,9 @@ idpf_vc_dealloc_vectors(struct idpf_vport *vport)
>  	int err, len;
> 
>  	alloc_vec = vport->recv_vectors;
> +	if (alloc_vec == NULL)
> +		return -EINVAL;
> +
Would it be better to check before idpf_vc_dealloc_vectors?
  
Xing, Beilei Nov. 18, 2022, 7:05 a.m. UTC | #2
> -----Original Message-----
> From: Wu, Jingjing <jingjing.wu@intel.com>
> Sent: Friday, November 18, 2022 2:24 PM
> To: Xing, Beilei <beilei.xing@intel.com>
> Cc: dev@dpdk.org; Peng, Yuan <yuan.peng@intel.com>
> Subject: RE: [PATCH v2] net/idpf: fix crash when launching l3fwd
> 
> > -
> >  	if (conf->txmode.mq_mode != RTE_ETH_MQ_TX_NONE) {
> >  		PMD_INIT_LOG(ERR, "Multi-queue TX mode %d is not
> supported",
> >  			     conf->txmode.mq_mode);
> > diff --git a/drivers/net/idpf/idpf_vchnl.c
> > b/drivers/net/idpf/idpf_vchnl.c index ac6486d4ef..88770447f8 100644
> > --- a/drivers/net/idpf/idpf_vchnl.c
> > +++ b/drivers/net/idpf/idpf_vchnl.c
> > @@ -1197,6 +1197,9 @@ idpf_vc_dealloc_vectors(struct idpf_vport *vport)
> >  	int err, len;
> >
> >  	alloc_vec = vport->recv_vectors;
> > +	if (alloc_vec == NULL)
> > +		return -EINVAL;
> > +
> Would it be better to check before idpf_vc_dealloc_vectors?
Make sense, will update in next version.
  

Patch

diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index 20f088eb80..51fc97bf7b 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -372,13 +372,6 @@  idpf_dev_configure(struct rte_eth_dev *dev)
 		return -ENOTSUP;
 	}
 
-	if ((dev->data->nb_rx_queues == 1 && conf->rxmode.mq_mode != RTE_ETH_MQ_RX_NONE) ||
-	    (dev->data->nb_rx_queues > 1 && conf->rxmode.mq_mode != RTE_ETH_MQ_RX_RSS)) {
-		PMD_INIT_LOG(ERR, "Multi-queue packet distribution mode %d is not supported",
-			     conf->rxmode.mq_mode);
-		return -ENOTSUP;
-	}
-
 	if (conf->txmode.mq_mode != RTE_ETH_MQ_TX_NONE) {
 		PMD_INIT_LOG(ERR, "Multi-queue TX mode %d is not supported",
 			     conf->txmode.mq_mode);
diff --git a/drivers/net/idpf/idpf_vchnl.c b/drivers/net/idpf/idpf_vchnl.c
index ac6486d4ef..88770447f8 100644
--- a/drivers/net/idpf/idpf_vchnl.c
+++ b/drivers/net/idpf/idpf_vchnl.c
@@ -1197,6 +1197,9 @@  idpf_vc_dealloc_vectors(struct idpf_vport *vport)
 	int err, len;
 
 	alloc_vec = vport->recv_vectors;
+	if (alloc_vec == NULL)
+		return -EINVAL;
+
 	vcs = &alloc_vec->vchunks;
 
 	len = sizeof(struct virtchnl2_vector_chunks) +