regex/mlx5: fix improper memory object check

Message ID tencent_4CA38D308974C5CCF2789C12444CEBDC7F0A@qq.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series regex/mlx5: fix improper memory object check |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing warning Testing issues

Commit Message

Weiguo Li Jan. 25, 2022, 11:51 a.m. UTC
  Fixes: e3dbbf718ebc ("regex/mlx5: support configuration")

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
---
 drivers/regex/mlx5/mlx5_rxp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Monjalon Feb. 10, 2022, 3:35 p.m. UTC | #1
25/01/2022 12:51, Weiguo Li:
> Fixes: e3dbbf718ebc ("regex/mlx5: support configuration")

Adding Cc stable@dpdk.org for backport.

> Signed-off-by: Weiguo Li <liwg06@foxmail.com>
> ---
>  drivers/regex/mlx5/mlx5_rxp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/regex/mlx5/mlx5_rxp.c b/drivers/regex/mlx5/mlx5_rxp.c
> index 5ead3ca341..51b6e71376 100644
> --- a/drivers/regex/mlx5/mlx5_rxp.c
> +++ b/drivers/regex/mlx5/mlx5_rxp.c
> @@ -148,7 +148,7 @@ mlx5_regex_configure(struct rte_regexdev *dev,
>  	dev->data->dev_conf.nb_queue_pairs = priv->nb_queues;
>  	priv->qps = rte_zmalloc(NULL, sizeof(struct mlx5_regex_qp) *
>  				priv->nb_queues, 0);
> -	if (!priv->nb_queues) {
> +	if (!priv->qps) {
>  		DRV_LOG(ERR, "can't allocate qps memory");

This mistake would have been caught earlier if the coding style was respected:
a pointer should be explictly compared with NULL.

Applied, thanks.
  

Patch

diff --git a/drivers/regex/mlx5/mlx5_rxp.c b/drivers/regex/mlx5/mlx5_rxp.c
index 5ead3ca341..51b6e71376 100644
--- a/drivers/regex/mlx5/mlx5_rxp.c
+++ b/drivers/regex/mlx5/mlx5_rxp.c
@@ -148,7 +148,7 @@  mlx5_regex_configure(struct rte_regexdev *dev,
 	dev->data->dev_conf.nb_queue_pairs = priv->nb_queues;
 	priv->qps = rte_zmalloc(NULL, sizeof(struct mlx5_regex_qp) *
 				priv->nb_queues, 0);
-	if (!priv->nb_queues) {
+	if (!priv->qps) {
 		DRV_LOG(ERR, "can't allocate qps memory");
 		rte_errno = ENOMEM;
 		return -rte_errno;