Skip to content

Commit

Permalink
app/crypto-perf: check memory allocation
Browse files Browse the repository at this point in the history
[ upstream commit 37c0359 ]

Return value of a function 'rte_zmalloc' is dereferenced without
checking, and it may call segmentation fault.

This patch fixed it.

Fixes: f8be178 ("app/crypto-perf: introduce performance test application")

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
  • Loading branch information
hushenggitcount authored and cpaelzer committed Jun 10, 2021
1 parent c19da5e commit 02d8cd1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/test-crypto-perf/cperf_options_parsing.c
Expand Up @@ -495,6 +495,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;

Expand Down

0 comments on commit 02d8cd1

Please sign in to comment.