From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0747FA00C5; Sat, 9 Jul 2022 13:02:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 91B354021F; Sat, 9 Jul 2022 13:02:46 +0200 (CEST) Received: from out203-205-221-191.mail.qq.com (out203-205-221-191.mail.qq.com [203.205.221.191]) by mails.dpdk.org (Postfix) with ESMTP id 668FF4021E for ; Sat, 9 Jul 2022 13:02:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1657364560; bh=TtSCvmmoxM06CWra51yp4YPOwYQSyf1EsvNWTgAZr80=; h=From:To:Cc:Subject:Date; b=fwH2CqPfd4v+0VSqGHYutmIfnPRUUR2wq62NzRTgIOXLeh9V/GFemU7p8RePWxpDB TH9FQbmgNfk6yZVQpjb9koyUmSHSTrKYrs2045CLUJZrjkym32h13zJ2u1Rt2OQ8i3 MUyligOxhn7ZkfwabCFyQm5bNlrtw5Sst9MvWS3M= Received: from localhost.localdomain ([202.192.80.120]) by newxmesmtplogicsvrszb7.qq.com (NewEsmtp) with SMTP id A03B653; Sat, 09 Jul 2022 19:02:32 +0800 X-QQ-mid: xmsmtpt1657364552td9rro8wc Message-ID: X-QQ-XMAILINFO: NkHKfw09D6j8HdmFDAUle0/2vbaLBR7ehxsU1FkHR5tp9rYkS8QHEhLb6CzNkG 1ITT+DEzB4yLzMagoai6LYKkJpA5WWwbQhM0F8D6GncCEVc3HAUm6HWW4bgVmAtwTthutqc4YG2V 3EvX0coAB3trOIHCb7AeHGPKD2ZzKbv4qoNF742iJ8BENkIwuX70y/a2R7Kvq2VoYXsZBIXA1Woo Nb7mH8QX42thjUr1pQDurdDU6AnLZ7SCv9guEU1D4cYDbK1qwTHfG9dcGZHvwXhrZQ5RKM866UOu NOTFr7HqNxT2x4O+R8t+DXJM1QU9X78ThNpApiFVLDmnKiTI1nlmqd9f+P6LtPqFM8rjXIq1M3M3 zVoLhqv2aqLSXR+EkFfniq7dLzLzwJez/jgrZhx/xnPa50DQyLToZGqk8VRWErf2x+kDfuxvsP4k KSNVcdodOZ+jgFacZNGqQxIHLLEgK4RLBjH3eMfhIOGT8oIZv2qw1aRpLZpDvsH/BCEAIHbnjO+A +seLTxWAiuSzg625AXGbvNMphfiAhptzPiHhJHbZAJM3QVEzDRhVaTjz9weij+/H/JDXg1I0wxkL eVGA83r6kXZkZjl2GbBB+5sQkrY6fB/TSFQRzLK8qvaAcjofsDwKkaxuqqCfun0aZd6XwGqZBjdn oIKkCEyUXtQdzVU6MpnPrJPVlnStZGU2H0f5hOQ1RZ31WF3bRT+c10XMJiXZpfGBdMfpERBa3418 GPyH4YFZlGIIkiCVm0GrBQHiRer2lCAd/mcYjIIk4rSKHT3vSU0VobhLF5e99x4FKGzLUirhr6YJ cGGcfT3BUPKrwK8WgtxV8fLa0iDZq0XTmFAyTXDesyf0Acb21te93OOssGK3+6fTuzZ88U675ucO jE1ARGsDHlYHyWdbIasQKdrm1wQdsqmnpGRgWKtg0Nll+cR3jhb5M= From: 835703180@qq.com To: chandu@amd.com Cc: dev@dpdk.org, Shiqi Liu <835703180@qq.com> Subject: [PATCH] crypto/ccp: Check for the NULL pointer after calling rte_malloc Date: Sat, 9 Jul 2022 19:01:15 +0800 X-OQ-MSGID: <20220709110115.1643-1-835703180@qq.com> X-Mailer: git-send-email 2.35.1.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Shiqi Liu <835703180@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@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