crypto/mlx5: fix leaks on probing failure
authorMichael Baum <michaelba@nvidia.com>
Thu, 29 Jul 2021 06:50:00 +0000 (09:50 +0300)
committerAkhil Goyal <gakhil@marvell.com>
Fri, 30 Jul 2021 19:08:19 +0000 (21:08 +0200)
In crypto driver probing, there are two validations after context
allocation.

When one of them fails, the context structure was not freed what caused
a memory leak.

Free it.

Fixes: debb27ea3442 ("crypto/mlx5: create login object using DevX")
Fixes: e8db4413cba5 ("crypto/mlx5: add keytag configuration")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/crypto/mlx5/mlx5_crypto.c

index ea734f4..b3d5200 100644 (file)
@@ -1021,12 +1021,14 @@ mlx5_crypto_dev_probe(struct rte_device *dev)
        ret = mlx5_crypto_parse_devargs(dev->devargs, &devarg_prms);
        if (ret) {
                DRV_LOG(ERR, "Failed to parse devargs.");
+               claim_zero(mlx5_glue->close_device(ctx));
                return -rte_errno;
        }
        login = mlx5_devx_cmd_create_crypto_login_obj(ctx,
                                                      &devarg_prms.login_attr);
        if (login == NULL) {
                DRV_LOG(ERR, "Failed to configure login.");
+               claim_zero(mlx5_glue->close_device(ctx));
                return -rte_errno;
        }
        crypto_dev = rte_cryptodev_pmd_create(ibv->name, dev,