diff mbox series

[v3] app/crypto-perf: fix dereference of null return

Message ID 1620281639-54472-1-git-send-email-humin29@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers show
Series [v3] app/crypto-perf: fix dereference of null return | expand

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/checkpatch success coding style OK

Commit Message

Min Hu (Connor) May 6, 2021, 6:13 a.m. UTC
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(+)

Comments

Akhil Goyal May 12, 2021, 4:13 p.m. UTC | #1
> 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.
Applied to dpdk-next-crypto

Thanks.
diff mbox series

Patch

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;