net/ixgbe: add param check when tx_queue or rx_queqe is null

Message ID 20240323144842.12331-1-keivinwang@126.com (mailing list archive)
State Changes Requested
Delegated to: Bruce Richardson
Headers
Series net/ixgbe: add param check when tx_queue or rx_queqe is null |

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/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/iol-abi-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-arm64-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

Commit Message

keivinwang March 23, 2024, 2:48 p.m. UTC
  add param check when tx_queue or rx_queqe is null.

Signed-off-by: keivinwang <keivinwang@126.com>
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
  

Comments

Bruce Richardson April 4, 2024, 3:57 p.m. UTC | #1
On Sat, Mar 23, 2024 at 10:48:42PM +0800, keivinwang wrote:
> add param check when tx_queue or rx_queqe is null.
> 

Hi,

trying to get some context on this patch. Have you encountered a situation
where there are actually NULL parameters getting passed to the functions,
or where an rx queue is unexpectedly NULL? If so, while adding NULL checks
is not a big issue in itself, the values being NULL may indicate a more
serious underlying issue we need to investigate.

> Signed-off-by: keivinwang <keivinwang@126.com>

For a sign-off, the general format is to have both firstname and
second/family name given as separate words.

Thanks,
/Bruce

> ---
>  drivers/net/ixgbe/ixgbe_rxtx.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
> index f6c17d4efb..245b3527db 100644
> --- a/drivers/net/ixgbe/ixgbe_rxtx.c
> +++ b/drivers/net/ixgbe/ixgbe_rxtx.c
> @@ -2539,6 +2539,8 @@ static const struct ixgbe_txq_ops def_txq_ops = {
>  void __rte_cold
>  ixgbe_set_tx_function(struct rte_eth_dev *dev, struct ixgbe_tx_queue *txq)
>  {
> +	if (txq == NULL)
> +		return;

Have you encountered a situation where this function can be given a null
parameter?

>  	/* Use a simple Tx queue (no offloads, no multi segs) if possible */
>  	if ((txq->offloads == 0) &&
>  #ifdef RTE_LIB_SECURITY
> @@ -4953,12 +4955,13 @@ ixgbe_set_rx_function(struct rte_eth_dev *dev)
>  
>  	for (i = 0; i < dev->data->nb_rx_queues; i++) {
>  		struct ixgbe_rx_queue *rxq = dev->data->rx_queues[i];
> -

Similarly here, if nb_rx_queues == X, is it possible a queue between
0..X-1 to be NULL?

> -		rxq->rx_using_sse = rx_using_sse;
> +		if (rxq) {
> +			rxq->rx_using_sse = rx_using_sse;
>  #ifdef RTE_LIB_SECURITY
> -		rxq->using_ipsec = !!(dev->data->dev_conf.rxmode.offloads &
> -				RTE_ETH_RX_OFFLOAD_SECURITY);
> +			rxq->using_ipsec = !!(dev->data->dev_conf.rxmode.offloads &
> +					RTE_ETH_RX_OFFLOAD_SECURITY);
>  #endif
> +		}
>  	}
  

Patch

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index f6c17d4efb..245b3527db 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -2539,6 +2539,8 @@  static const struct ixgbe_txq_ops def_txq_ops = {
 void __rte_cold
 ixgbe_set_tx_function(struct rte_eth_dev *dev, struct ixgbe_tx_queue *txq)
 {
+	if (txq == NULL)
+		return;
 	/* Use a simple Tx queue (no offloads, no multi segs) if possible */
 	if ((txq->offloads == 0) &&
 #ifdef RTE_LIB_SECURITY
@@ -4953,12 +4955,13 @@  ixgbe_set_rx_function(struct rte_eth_dev *dev)
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		struct ixgbe_rx_queue *rxq = dev->data->rx_queues[i];
-
-		rxq->rx_using_sse = rx_using_sse;
+		if (rxq) {
+			rxq->rx_using_sse = rx_using_sse;
 #ifdef RTE_LIB_SECURITY
-		rxq->using_ipsec = !!(dev->data->dev_conf.rxmode.offloads &
-				RTE_ETH_RX_OFFLOAD_SECURITY);
+			rxq->using_ipsec = !!(dev->data->dev_conf.rxmode.offloads &
+					RTE_ETH_RX_OFFLOAD_SECURITY);
 #endif
+		}
 	}
 }