app/crypto-perf: fix test file memory leak
PATCH 1/1 app/crypto-perf: fix test file memory leak
A memory leak was detected using the AddressSanitizer tool, when running the crypto-perf application with a test vector file.
The strdup function used returns a pointer to a null-terminated byte string, which must be freed after use. This patch frees the pointer in an error case, and also after a successful run.
--- app/test-crypto-perf/cperf_options_parsing.c | 1 + app/test-crypto-perf/cperf_test_vector_parsing.c | 1 + 2 files changed, 2 insertions(+)
app/test-crypto-perf/cperf_options_parsing.c +1 -0
@@ -519,6 +519,7 @@ parse_test_file(struct cperf_options *opts,if (access (opts->test_file,F_OK ) !=-1 )return 0 ;RTE_LOG (ERR ,USER1 ,"Test vector file doesn't exist\n" ); +free (opts->test_file);return -1 ; }
app/test-crypto-perf/cperf_test_vector_parsing.c +1 -0
@@ -30,6 +30,7 @@ free_test_vector(struct cperf_test_vector *vector, struct cperf_options *opts)rte_free (vector->cipher_key.data);rte_free (vector->auth_key.data);rte_free (vector->ciphertext.data); +free (opts->test_file); }rte_free (vector);
Signature · 1 line
2.25.1
Quoted 7 lines
A memory leak was detected using the AddressSanitizer tool, when running the crypto-perf application with a test vector file.
The strdup function used returns a pointer to a null-terminated byte string, which must be freed after use. This patch frees the pointer in an error case, and also after a successful run.
Quoted 5 lines
Fixes f8be1786b1b8 ("app/crypto-perf: introduce performance testapplication")
Cc: [email protected]Signed-off-by Ciara Power <[email protected]>
Applied to dpdk-next-crypto
Quoted 54 lines
-----Original Message-----
From: Power, Ciara <[email protected]>
Sent: Friday, March 10, 2023 1:20 PM
To: [email protected]
Cc: Ji, Kai <[email protected]>; Power, Ciara <[email protected]>; [email protected]
Subject: [PATCH] app/crypto-perf: fix test file memory leakA memory leak was detected using the AddressSanitizer tool, when running the crypto-perf application with a test vector file.
The strdup function used returns a pointer to a null-terminated byte string, which must be freed after use. This patch frees the pointer in an error case, and also after a successful run.
Fixes f8be1786b1b8 ("app/crypto-perf: introduce performance testapplication")
Cc: [email protected]Signed-off-by Ciara Power <[email protected]>--- app/test-crypto-perf/cperf_options_parsing.c | 1 + app/test-crypto-perf/cperf_test_vector_parsing.c | 1 + 2 files changed, 2 insertions(+)app/test- renamed from app/test-crypto-perf/cperf_options_parsing.c +0
-0
crypto-perf/cperf_options_parsing.c
index8c9f632590..26136a52ae100644app/test-crypto-perf/cperf_options_parsing.c +1
-0@@ -519,6 +519,7 @@ parse_test_file(struct cperf_options *opts,if (access (opts->test_file,F_OK ) !=-1 )return 0 ;RTE_LOG (ERR ,USER1 ,"Test vector file doesn't exist\n" ); +free (opts->test_file);return -1 ; }app/test- renamed from app/test-crypto-perf/cperf_test_vector_parsing.c +0
-0
crypto-perf/cperf_test_vector_parsing.c
index98e46c3381..737d61d4af100644app/test-crypto-perf/cperf_test_vector_parsing.c +1
-0@@ -30,6 +30,7 @@ free_test_vector(struct cperf_test_vector *vector, struct cperf_options *opts) rte_free(vector->cipher_key.data);rte_free (vector->auth_key.data);rte_free (vector->ciphertext.data); +free (opts->test_file); }
rte_free(vector);
--
2.25.1