[PATCH] crypto/ccp: Check for the NULL pointer after calling rte_malloc

Namburu, Chandu-babu chandu at amd.com
Wed Jul 20 08:29:06 CEST 2022


[Public]

Acked-by: Chandubabu Namburu <chandu at amd.com>

-----Original Message-----
From: 835703180 at qq.com <835703180 at qq.com> 
Sent: Saturday, July 9, 2022 4:31 PM
To: Namburu, Chandu-babu <chandu at amd.com>
Cc: dev at dpdk.org; Shiqi Liu <835703180 at qq.com>
Subject: [PATCH] crypto/ccp: Check for the NULL pointer after calling rte_malloc

From: Shiqi Liu <835703180 at qq.com>

As the possible failure of the rte_malloc(), the not_checked and checked could be NULL pointer.
Therefore, it should be better to check it in order to avoid the dereference of the NULL pointer.

Fixes: 09a0fd736a0 ("crypto/ccp: enable IOMMU")
Signed-off-by: Shiqi Liu <835703180 at qq.com>
---
 drivers/crypto/ccp/rte_ccp_pmd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/crypto/ccp/rte_ccp_pmd.c b/drivers/crypto/ccp/rte_ccp_pmd.c
index a35a8cd775..776f928864 100644
--- a/drivers/crypto/ccp/rte_ccp_pmd.c
+++ b/drivers/crypto/ccp/rte_ccp_pmd.c
@@ -301,6 +301,9 @@ cryptodev_ccp_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	};
 
 	sha_ctx = (void *)rte_malloc(NULL, SHA512_DIGEST_SIZE, 64);
+	if (sha_ctx == NULL) {
+		return -ENOMEM;
+	}
 	if (ccp_pmd_init_done) {
 		RTE_LOG(INFO, PMD, "CCP PMD already initialized\n");
 		return -EFAULT;
--
2.35.1.windows.2


More information about the dev mailing list