From patchwork Thu May 6 06:13:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 92985 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9D2E9A0A02; Thu, 6 May 2021 08:14:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1ED29410DB; Thu, 6 May 2021 08:14:06 +0200 (CEST) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mails.dpdk.org (Postfix) with ESMTP id BD33F40040 for ; Thu, 6 May 2021 08:14:04 +0200 (CEST) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FbNVW64YGzmfcf; Thu, 6 May 2021 14:10:43 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Thu, 6 May 2021 14:13:56 +0800 From: "Min Hu (Connor)" To: CC: , , Date: Thu, 6 May 2021 14:13:59 +0800 Message-ID: <1620281639-54472-1-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1619163678-37202-1-git-send-email-humin29@huawei.com> References: <1619163678-37202-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v3] app/crypto-perf: fix dereference of null return 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 Sender: "dev" Return value of a function 'rte_zmalloc' is dereferenced without checking, and it may call segmentation fault. This patch fixed it. Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test application") Cc: stable@dpdk.org Signed-off-by: Min Hu (Connor) --- v3: * fix compiling warning. --- app/test-crypto-perf/cperf_options_parsing.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c index 40b6dfb..e84f56c 100644 --- a/app/test-crypto-perf/cperf_options_parsing.c +++ b/app/test-crypto-perf/cperf_options_parsing.c @@ -506,6 +506,12 @@ parse_test_name(struct cperf_options *opts, { char *test_name = (char *) rte_zmalloc(NULL, sizeof(char) * (strlen(arg) + 3), 0); + if (test_name == NULL) { + RTE_LOG(ERR, USER1, "Failed to rte zmalloc with size: %zu\n", + strlen(arg) + 3); + return -1; + } + snprintf(test_name, strlen(arg) + 3, "[%s]", arg); opts->test_name = test_name;