[v8,05/10] regex/mlx5: fix segmentation fault during error unwinding
diff mbox series

Message ID 20200723200910.376581-6-parav@mellanox.com
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers show
Series
  • Improve mlx5 PMD driver framework for multiple classes
Related show

Checks

Context Check Description
ci/Intel-compilation fail apply issues
ci/checkpatch warning coding style issues

Commit Message

Parav Pandit July 23, 2020, 8:09 p.m. UTC
When fail to initialize the device, avoid segmentation fault while
accessing unintialized priv.

Fixes: cfc672a90b74 ("regex/mlx5: support probing")
Signed-off-by: Parav Pandit <parav@mellanox.com>
---
 drivers/regex/mlx5/mlx5_regex.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c
index 1ca5bfe9b..36ae9f809 100644
--- a/drivers/regex/mlx5/mlx5_regex.c
+++ b/drivers/regex/mlx5/mlx5_regex.c
@@ -137,17 +137,17 @@  mlx5_regex_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	if (ret) {
 		DRV_LOG(ERR, "Unable to read HCA capabilities.");
 		rte_errno = ENOTSUP;
-		goto error;
+		goto dev_error;
 	} else if (!attr.regex || attr.regexp_num_of_engines == 0) {
 		DRV_LOG(ERR, "Not enough capabilities to support RegEx, maybe "
 			"old FW/OFED version?");
 		rte_errno = ENOTSUP;
-		goto error;
+		goto dev_error;
 	}
 	if (mlx5_regex_engines_status(ctx, 2)) {
 		DRV_LOG(ERR, "RegEx engine error.");
 		rte_errno = ENOMEM;
-		goto error;
+		goto dev_error;
 	}
 	priv = rte_zmalloc("mlx5 regex device private", sizeof(*priv),
 			   RTE_CACHE_LINE_SIZE);
@@ -200,6 +200,7 @@  mlx5_regex_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		mlx5_glue->devx_free_uar(priv->uar);
 	if (priv->regexdev)
 		rte_regexdev_unregister(priv->regexdev);
+dev_error:
 	if (ctx)
 		mlx5_glue->close_device(ctx);
 	if (priv)