patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] app/crypto-perf: fix test file memory leak
@ 2023-03-10 13:20 Ciara Power
  2023-03-11 19:02 ` [EXT] " Akhil Goyal
  2023-03-13 10:21 ` Ji, Kai
  0 siblings, 2 replies; 3+ messages in thread
From: Ciara Power @ 2023-03-10 13:20 UTC (permalink / raw)
  To: dev; +Cc: kai.ji, Ciara Power, stable

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.

Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test application")
Cc: stable@dpdk.org

Signed-off-by: Ciara Power <ciara.power@intel.com>
---
 app/test-crypto-perf/cperf_options_parsing.c     | 1 +
 app/test-crypto-perf/cperf_test_vector_parsing.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c
index 8c9f632590..26136a52ae 100644
--- a/app/test-crypto-perf/cperf_options_parsing.c
+++ b/app/test-crypto-perf/cperf_options_parsing.c
@@ -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;
 }
diff --git a/app/test-crypto-perf/cperf_test_vector_parsing.c b/app/test-crypto-perf/cperf_test_vector_parsing.c
index 98e46c3381..737d61d4af 100644
--- a/app/test-crypto-perf/cperf_test_vector_parsing.c
+++ b/app/test-crypto-perf/cperf_test_vector_parsing.c
@@ -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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-13 10:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10 13:20 [PATCH] app/crypto-perf: fix test file memory leak Ciara Power
2023-03-11 19:02 ` [EXT] " Akhil Goyal
2023-03-13 10:21 ` Ji, Kai

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).