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 93D39A00C3; Tue, 25 Jan 2022 15:22:58 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 203D3426EF; Tue, 25 Jan 2022 15:22:58 +0100 (CET) Received: from out162-62-57-49.mail.qq.com (out162-62-57-49.mail.qq.com [162.62.57.49]) by mails.dpdk.org (Postfix) with ESMTP id 58C4E426E4 for ; Tue, 25 Jan 2022 15:22:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1643120574; bh=29FRMBWKRrU0eic7NwDR0I6WvtmlY0q1Wbw/ZPsJYhA=; h=From:To:Cc:Subject:Date; b=a1Gh8Vpt+tHKASYUufgVJ4K7Pl96pjDxmKwm67UFfchFGrV180Mt47wyfYbgiNH47 WQPJ2jbEHaqGlRWE1VfNfRr5dt3V1NGlceNBScBM2WAtwSckJ08IPOEsXi/5uX0hZu d7V1Z1Znml0Ga9BXtSLZWxJ2oEydaJwBDIxmsKYA= Received: from localhost.localdomain ([111.193.130.237]) by newxmesmtplogicsvrszc6.qq.com (NewEsmtp) with SMTP id 5ACB1645; Tue, 25 Jan 2022 22:22:44 +0800 X-QQ-mid: xmsmtpt1643120564tmavqnmbh Message-ID: X-QQ-XMAILINFO: NmzMINE5aCWaXA6VycHGa/5OeVirZITHZFOeKtCQPgq2qhP4yBeU2JHfjSHskJ SeGWkoxa4MBPRJAFtyW/K+ceWiJp8exN+gkVSEi7cN3ca2s4ZnQB1PHErb+d+62NtFg9S51blKcT ztYPq7qUesB6TwTBZBmzE/INiaLPDeZG5+pl0LsOAamcdqd/6V+iLRsKZ7T2PKMizDBwljGt9rOd 4tTEyGL8bcN+1ZjTO0tvhY9tWt/qxQWLVrwz60aZT7h2p//94KwZdyXA+PbswMnAYnJ9lXI5M40m SY4aKlGzry+fcWJRAwaL1if6KnmhS1obZ1hxMfV6gZD7F1oUn/KKNy/ytzfiZqPz6odpt+XXvrVK 7816k3PFdd81auL6iBkIb8R8StjKoW4bLcx+K4Tu/PkygVRg714rbYsja1T1I4pX1X3SvMs9gkRO Q0o1fnwMGCm0pWEasHlDiiC2bVEFpVtd1W3+2i10sqFc3kmX8HZjGB4cEaM4Hv+UQe3o7omKmabL b1Dwsrp5FO8vhINSiwIhp9o4EAOpGoMLnvivWfIk6JKK/ZlwG0E//C/E7xYmMKhmvCvW09YD57nx n3ROnbp4DnOrEyUCSlh0f/qr1cd79078ZvpeRVhQu3OVVdOIOBhpuBRRBQwCr4FvzPWBd25JS2cq ZSqZ4mzY8ThaWhyK2kQLcycRTcg63ZPzyT/poo9Oy7nNITCDfNhni6LY3VQzM+iO+w8MsQV4MuZ9 ONqjZXkcmJbDmHug5U6hzLh3X2KLmB391umWTavHmmEDlR9OEpqgatWb9xPEluwS952z4LQEdObr eByFE001347Shqd3vva2Qli2kxJSrdz8Sfo8T7KVGwROEpy/wnIjOALRl7Tyj32jE= From: Weiguo Li To: ashish.gupta@marvell.com Cc: dev@dpdk.org Subject: [PATCH] compress/octeontx: fix null pointer dereference Date: Tue, 25 Jan 2022 22:22:44 +0800 X-OQ-MSGID: <20220125142244.32140-1-liwg06@foxmail.com> X-Mailer: git-send-email 2.25.1 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 Check for memory allocation failure is added to avoid null pointer dereference. Signed-off-by: Weiguo Li --- drivers/compress/octeontx/otx_zip_pmd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/compress/octeontx/otx_zip_pmd.c b/drivers/compress/octeontx/otx_zip_pmd.c index dd62285b86..be6f0d358f 100644 --- a/drivers/compress/octeontx/otx_zip_pmd.c +++ b/drivers/compress/octeontx/otx_zip_pmd.c @@ -392,6 +392,8 @@ zip_pmd_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, } name = rte_malloc(NULL, RTE_COMPRESSDEV_NAME_MAX_LEN, 0); + if (name == NULL) + return (-ENOMEM); snprintf(name, RTE_COMPRESSDEV_NAME_MAX_LEN, "zip_pmd_%u_qp_%u", dev->data->dev_id, qp_id); @@ -399,8 +401,11 @@ zip_pmd_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, /* Allocate the queue pair data structure. */ qp = rte_zmalloc_socket(name, sizeof(*qp), RTE_CACHE_LINE_SIZE, socket_id); - if (qp == NULL) + if (qp == NULL) { + rte_free(name); return (-ENOMEM); + } + qp->name = name; -- 2.25.1