[1/7] regex/mlx5: fix jump to the wrong label

Message ID 1605718811-18652-1-git-send-email-michaelba@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [1/7] regex/mlx5: fix jump to the wrong label |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Michael Baum Nov. 18, 2020, 5 p.m. UTC
  The mlx5_regex_pci_probe function allocates a mlx5_regex_priv structure
using rte_zmalloc.

If the allocation fails, the function jumps to the dev_error label in
order to release previously allocated resources in the function.
However, in the dev_error label it attempts to refer to the internal
fields of the priv structure and if its allocation fails (as in this
case) it is actually dereferencing to NULL.

Replace the jump with an error label.

Fixes: 1db6ebd4ef58 ("regex/mlx5: fix crash on initialization failure")
Cc: stable@dpdk.org

Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
---
 drivers/regex/mlx5/mlx5_regex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Monjalon Nov. 22, 2020, 2:06 p.m. UTC | #1
18/11/2020 18:00, Michael Baum:
> The mlx5_regex_pci_probe function allocates a mlx5_regex_priv structure
> using rte_zmalloc.
> 
> If the allocation fails, the function jumps to the dev_error label in
> order to release previously allocated resources in the function.
> However, in the dev_error label it attempts to refer to the internal
> fields of the priv structure and if its allocation fails (as in this
> case) it is actually dereferencing to NULL.
> 
> Replace the jump with an error label.
> 
> Fixes: 1db6ebd4ef58 ("regex/mlx5: fix crash on initialization failure")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Michael Baum <michaelba@nvidia.com>
> Acked-by: Ori Kam <orika@nvidia.com>

Series applied, thanks
  

Patch

diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c
index 05048e7..c91c444 100644
--- a/drivers/regex/mlx5/mlx5_regex.c
+++ b/drivers/regex/mlx5/mlx5_regex.c
@@ -157,7 +157,7 @@ 
 	if (!priv) {
 		DRV_LOG(ERR, "Failed to allocate private memory.");
 		rte_errno = ENOMEM;
-		goto error;
+		goto dev_error;
 	}
 	priv->ctx = ctx;
 	priv->nb_engines = 2; /* attr.regexp_num_of_engines */