[20/20] regex/mlx5: fix a memory leak in error handling

Message ID tencent_1278C24FEF22E2740EBE2547AA45E8638209@qq.com (mailing list archive)
State Changes Requested, archived
Delegated to: David Marchand
Headers
Series fix memory leaks in error handling |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build fail github build: failed
ci/iol-broadcom-Functional success Functional Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-broadcom-Performance success Performance 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-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Weiguo Li Feb. 22, 2022, 6:28 p.m. UTC
  When rxp_create_mkey() failed the function return, 'ptr' was not
freed which caused a memory leak.

Fixes: 9fa82d287f65 ("regex/mlx5: move RXP to CrSpace")

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

Patch

diff --git a/drivers/regex/mlx5/mlx5_rxp.c b/drivers/regex/mlx5/mlx5_rxp.c
index ed3af15e40..4da29a2a06 100644
--- a/drivers/regex/mlx5/mlx5_rxp.c
+++ b/drivers/regex/mlx5/mlx5_rxp.c
@@ -117,8 +117,10 @@  mlx5_regex_rules_db_import(struct rte_regexdev *dev,
 	rte_memcpy(ptr, rule_db, rule_db_len);
 	/* Register umem and create rof mkey. */
 	ret = rxp_create_mkey(priv, ptr, rule_db_len, /*access=*/7, &mkey);
-	if (ret < 0)
+	if (ret < 0) {
+		rte_free(ptr);
 		return ret;
+	}
 
 	for (id = 0; id < priv->nb_engines; id++) {
 		ret = mlx5_devx_regex_rules_program(priv->cdev->ctx, id,