[PATCH] crypto/zsda: fix null dereference on device creation failure

Oleg Kotkov Oleg.Kotkov at kaspersky.com
Wed Dec 2 11:32:10 CET 2026


If rte_cryptodev_pmd_create() returns NULL, the error path passes that
pointer to rte_cryptodev_pmd_destroy(). The destroy function dereferences
it, which can crash the primary process during PCI probe.

Skip device destruction when creation fails. Only destroy the device if
the subsequent reservation of the capabilities memzone fails.

Fixes: 1ae3a7d97b67 ("crypto/zsda: add skeleton")
Cc: stable at dpdk.org

Signed-off-by: Oleg Kotkov <Oleg.Kotkov at kaspersky.com>
---
 drivers/crypto/zsda/zsda_crypto_pmd.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/zsda/zsda_crypto_pmd.c b/drivers/crypto/zsda/zsda_crypto_pmd.c
index 181e19f9f2..5ff5c1b716 100644
--- a/drivers/crypto/zsda/zsda_crypto_pmd.c
+++ b/drivers/crypto/zsda/zsda_crypto_pmd.c
@@ -286,7 +286,7 @@ zsda_crypto_dev_create(struct zsda_pci_device *zsda_pci_dev)
 
 	if (cryptodev == NULL) {
 		ZSDA_LOG(ERR, "Failed! rte_cryptodev_pmd_create");
-		goto error;
+		goto cryptodev_create_error;
 	}
 
 	dev_info->crypto_rte_dev.name = cryptodev->data->name;
@@ -319,7 +319,7 @@ zsda_crypto_dev_create(struct zsda_pci_device *zsda_pci_dev)
 
 	if (crypto_dev_priv->capa_mz == NULL) {
 		ZSDA_LOG(ERR, "Failed! crypto_dev_priv->capa_mz");
-		goto error;
+		goto capa_mz_error;
 	}
 
 	memcpy(crypto_dev_priv->capa_mz->addr, capabilities, capa_size);
@@ -329,9 +329,10 @@ zsda_crypto_dev_create(struct zsda_pci_device *zsda_pci_dev)
 
 	return ZSDA_SUCCESS;
 
-error:
-
+capa_mz_error:
 	rte_cryptodev_pmd_destroy(cryptodev);
+
+cryptodev_create_error:
 	memset(&dev_info->crypto_rte_dev, 0, sizeof(dev_info->crypto_rte_dev));
 
 	return -EFAULT;
-- 
2.43.0



More information about the stable mailing list