DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>, <thomas@monjalon.net>, <gakhil@marvell.com>
Subject: [dpdk-dev] [PATCH v3] app/crypto-perf: fix dereference of null return
Date: Thu, 6 May 2021 14:13:59 +0800	[thread overview]
Message-ID: <1620281639-54472-1-git-send-email-humin29@huawei.com> (raw)
In-Reply-To: <1619163678-37202-1-git-send-email-humin29@huawei.com>

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) <humin29@huawei.com>
---
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;
 
-- 
2.7.4


  parent reply	other threads:[~2021-05-06  6:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-23  7:41 [dpdk-dev] [PATCH] " Min Hu (Connor)
2021-04-29 11:24 ` [dpdk-dev] [PATCH v2] " Min Hu (Connor)
2021-05-05 15:06   ` [dpdk-dev] [EXT] " Akhil Goyal
2021-05-06  6:13 ` Min Hu (Connor) [this message]
2021-05-12 16:13   ` [dpdk-dev] [EXT] [PATCH v3] " Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1620281639-54472-1-git-send-email-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=gakhil@marvell.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).