crypto/mlx5: fix crypto dev leak

Message ID 20231109073317.1311513-1-suanmingm@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series crypto/mlx5: fix crypto dev leak |

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/github-robot: build success github build: passed
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Suanming Mou Nov. 9, 2023, 7:33 a.m. UTC
  For the case crypto initialize failed, the allocated crypto dev should
be destroyed, otherwise the dev leaked. Current PMD returns directly
instead of releasing the dev.

This commit fixes the crypto dev leak when initialize failed.

Fixes: a27f6a2e1f30 ("crypto/mlx5: split AES-XTS")
Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/crypto/mlx5/mlx5_crypto.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Akhil Goyal Nov. 9, 2023, 8:28 p.m. UTC | #1
> For the case crypto initialize failed, the allocated crypto dev should
> be destroyed, otherwise the dev leaked. Current PMD returns directly
> instead of releasing the dev.
> 
> This commit fixes the crypto dev leak when initialize failed.
> 
> Fixes: a27f6a2e1f30 ("crypto/mlx5: split AES-XTS")
> Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>
Applied to dpdk-next-crypto

Cc: stable@dpdk.org
  

Patch

diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c
index 081e96ad4d..4bac723c8b 100644
--- a/drivers/crypto/mlx5/mlx5_crypto.c
+++ b/drivers/crypto/mlx5/mlx5_crypto.c
@@ -383,12 +383,14 @@  mlx5_crypto_dev_probe(struct mlx5_common_device *cdev,
 	if (devarg_prms.is_aes_gcm) {
 		ret = mlx5_crypto_gcm_init(priv);
 		if (ret) {
+			rte_cryptodev_pmd_destroy(priv->crypto_dev);
 			DRV_LOG(ERR, "Failed to init AES-GCM crypto.");
 			return -ENOTSUP;
 		}
 	} else {
 		ret = mlx5_crypto_xts_init(priv);
 		if (ret) {
+			rte_cryptodev_pmd_destroy(priv->crypto_dev);
 			DRV_LOG(ERR, "Failed to init AES-XTS crypto.");
 			return -ENOTSUP;
 		}