summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo de Lara <pablo.de.lara.guarch@intel.com>2018-07-17 14:31:51 +0100
committerThomas Monjalon <thomas@monjalon.net>2018-07-26 21:52:31 +0200
commita4492ab49ec3b829745c9060a1719354e0a572b7 (patch)
tree0207d3b772b9f23a4d2d4b161053a9477e299057
parent0c992822901464d440534d337838fd08acf233d4 (diff)
downloaddpdk-a4492ab49ec3b829745c9060a1719354e0a572b7.zip
dpdk-a4492ab49ec3b829745c9060a1719354e0a572b7.tar.gz
dpdk-a4492ab49ec3b829745c9060a1719354e0a572b7.tar.xz
test/hash: fix potential memory leak
In the multiwriter test, if "found" array allocation failed, the memory of "keys" array, which was successfully allocated could not be freed, since by this time, tbl_multiwriter_test_params.keys was not set to this array, which is the pointer freed when finishing the test or when a failure happens. To solve this, tbl_multiwriter_test_params.keys is set to the "keys" address, just after allocating and filling the array. Fixes: be856325cba3 ("hash: add scalable multi-writer insertion with Intel TSX") Cc: stable@dpdk.org Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
-rw-r--r--test/test/test_hash_multiwriter.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/test/test/test_hash_multiwriter.c b/test/test/test_hash_multiwriter.c
index acd6a91..6a3eb10 100644
--- a/test/test/test_hash_multiwriter.c
+++ b/test/test/test_hash_multiwriter.c
@@ -154,16 +154,17 @@ test_hash_multiwriter(void)
goto err1;
}
+ for (i = 0; i < nb_entries; i++)
+ keys[i] = i;
+
+ tbl_multiwriter_test_params.keys = keys;
+
found = rte_zmalloc(NULL, sizeof(uint32_t) * nb_entries, 0);
if (found == NULL) {
printf("RTE_ZMALLOC failed\n");
goto err2;
}
- for (i = 0; i < nb_entries; i++)
- keys[i] = i;
-
- tbl_multiwriter_test_params.keys = keys;
tbl_multiwriter_test_params.found = found;
rte_atomic64_init(&gcycles);