app/crypto-perf: fix dereference of null return
PATCH 1/1 app/crypto-perf: fix dereference of null return
Return value of a function 'rte_zmalloc' is dereferenced without checking, and it may call segmentation fault.
This patch fixed it.
--- app/test-crypto-perf/cperf_options_parsing.c | 6 ++++++ 1 file changed, 6 insertions(+)
app/test-crypto-perf/cperf_options_parsing.c +6 -0
@@ -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;
Signature · 1 line
2.7.4
PATCH v2 1/1 app/crypto-perf: fix dereference of null return
Return value of a function 'rte_zmalloc' is dereferenced without checking, and it may call segmentation fault.
This patch fixed it.
---
v2:
* fix compiling warning.
--- app/test-crypto-perf/cperf_options_parsing.c | 6 ++++++ 1 file changed, 6 insertions(+)
app/test-crypto-perf/cperf_options_parsing.c +6 -0
@@ -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: %u\n" , +strlen (arg) +3 ); +return -1 ; + } +snprintf (test_name,strlen (arg) +3 ,"[%s]" , arg); opts->test_name = test_name;
Signature · 1 line
2.7.4
Quoted 5 lines
Return value of a function '
rte_zmalloc' is dereferenced without checking, and it may call segmentation fault.This patch fixed it.
Quoted 8 lines
Fixes f8be1786b1b8 ("app/crypto-perf: introduce performance testapplication")
Cc: [email protected]Signed-off-by Min Hu (Connor) <[email protected]>---
v2:
* fix compiling warning.
Please fix the compilation reported by CI
In file included from ../lib/eal/include/rte_bus.h:24:0,
from ../lib/eal/include/rte_eal.h:21,
from ../lib/eal/include/rte_lcore.h:16,
from ../lib/eal/include/generic/rte_spinlock.h:21,
from ../lib/eal/x86/include/rte_spinlock.h:12,
from ../lib/mempool/rte_mempool.h:44,
from ../lib/mbuf/rte_mbuf.h:38,
from ../lib/cryptodev/rte_crypto.h:20,
from ../lib/cryptodev/rte_cryptodev.h:22,
from ../app/test-crypto-perf/cperf_options_parsing.c:8:
../app/test-crypto-perf/cperf_options_parsing.c: In function ‘parse_test_name’:
../app/test-crypto-perf/cperf_options_parsing.c:511:19: error: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘size_t {aka long unsigned int}’ [-Werror=format=]
strlen(arg) + 3);
~~~~~~~~~~~~~~~^
../lib/eal/include/rte_log.h:348:25: note: in definition of macro ‘RTE_LOG’
RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__)PATCH v3 1/1 app/crypto-perf: fix dereference of null return
In reply to Min Hu (Connor)Return value of a function 'rte_zmalloc' is dereferenced without checking, and it may call segmentation fault.
This patch fixed it.
---
v3:
* fix compiling warning.
--- app/test-crypto-perf/cperf_options_parsing.c | 6 ++++++ 1 file changed, 6 insertions(+)
app/test-crypto-perf/cperf_options_parsing.c +6 -0
@@ -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;
Signature · 1 line
2.7.4
Akhil Goyal
AppliedQuoted 5 lines
Return value of a function '
rte_zmalloc' is dereferenced without checking, and it may call segmentation fault.This patch fixed it.
Quoted 8 lines
Fixes f8be1786b1b8 ("app/crypto-perf: introduce performance testapplication")
Cc: [email protected]Signed-off-by Min Hu (Connor) <[email protected]>---
v3:
* fix compiling warning.
Applied to dpdk-next-crypto
Thanks.