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 755C4A0548; Fri, 23 Apr 2021 09:41:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D90E4067E; Fri, 23 Apr 2021 09:41:15 +0200 (CEST) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mails.dpdk.org (Postfix) with ESMTP id 8145E4014F for ; Fri, 23 Apr 2021 09:41:13 +0200 (CEST) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FRR3N5LLxzpbLc; Fri, 23 Apr 2021 15:38:08 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Fri, 23 Apr 2021 15:41:06 +0800 From: "Min Hu (Connor)" To: CC: , , , Date: Fri, 23 Apr 2021 15:41:18 +0800 Message-ID: <1619163678-37202-1-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] 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) --- 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..5b2f7c3 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: %lu\n", + strlen(arg) + 3); + return -1; + } + snprintf(test_name, strlen(arg) + 3, "[%s]", arg); opts->test_name = test_name; -- 2.7.4