Skip to content

Commit 77e23b2

Browse files
committed
test/hash: check memory allocation
When reserving a specific memory amount, it was possible to pass the first allocations and fail on a later allocation where there was no check, resulting in a crash. It is fixed by stopping the test if allocation failed. Fixes: fd368e1 ("test/hash: test more corner cases") Fixes: 9c7d8ee ("test/hash: add RCU tests") Cc: [email protected] Signed-off-by: Thomas Monjalon <[email protected]> Reviewed-by: David Marchand <[email protected]>
1 parent 39b54f2 commit 77e23b2

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

app/test/test_hash_readwrite.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ test_hash_readwrite_worker(__rte_unused void *arg)
7070

7171
ret = rte_malloc(NULL, sizeof(int) *
7272
tbl_rw_test_param.num_insert, 0);
73+
if (ret == NULL) {
74+
printf("allocation failed\n");
75+
return -1;
76+
}
77+
7378
for (i = 0; i < rte_lcore_count(); i++) {
7479
if (worker_core_ids[i] == lcore_id)
7580
break;

app/test/test_hash_readwrite_lf_perf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,10 @@ test_hash_rcu_qsbr_writer_perf(struct rwc_perf *rwc_perf_results, int rwc_lf,
13101310

13111311
sz = rte_rcu_qsbr_get_memsize(RTE_MAX_LCORE);
13121312
rv = (struct rte_rcu_qsbr *)rte_zmalloc(NULL, sz, RTE_CACHE_LINE_SIZE);
1313+
if (rv == NULL) {
1314+
printf("allocation failed\n");
1315+
goto err;
1316+
}
13131317
rcu_config.v = rv;
13141318

13151319
if (rte_hash_rcu_qsbr_add(tbl_rwc_test_param.h, &rcu_config) < 0) {

0 commit comments

Comments
 (0)