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: fd368e1982bc ("test/hash: test more corner cases")
Cc: [email protected]

Signed-off-by: Thomas Monjalon <[email protected]>
---
 app/test/test_hash_readwrite.c         | 5 +++++
 app/test/test_hash_readwrite_lf_perf.c | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/app/test/test_hash_readwrite.c b/app/test/test_hash_readwrite.c
index 82fe03cc5a..22ccd6df6a 100644
--- a/app/test/test_hash_readwrite.c
+++ b/app/test/test_hash_readwrite.c
@@ -70,6 +70,11 @@ test_hash_readwrite_worker(__rte_unused void *arg)
 
        ret = rte_malloc(NULL, sizeof(int) *
                                tbl_rw_test_param.num_insert, 0);
+       if (ret == NULL) {
+               printf("allocation failed\n");
+               return -1;
+       }
+
        for (i = 0; i < rte_lcore_count(); i++) {
                if (worker_core_ids[i] == lcore_id)
                        break;
diff --git a/app/test/test_hash_readwrite_lf_perf.c 
b/app/test/test_hash_readwrite_lf_perf.c
index 864c3059d9..bef987d29d 100644
--- a/app/test/test_hash_readwrite_lf_perf.c
+++ b/app/test/test_hash_readwrite_lf_perf.c
@@ -1310,6 +1310,10 @@ test_hash_rcu_qsbr_writer_perf(struct rwc_perf 
*rwc_perf_results, int rwc_lf,
 
        sz = rte_rcu_qsbr_get_memsize(RTE_MAX_LCORE);
        rv = (struct rte_rcu_qsbr *)rte_zmalloc(NULL, sz, RTE_CACHE_LINE_SIZE);
+       if (rv == NULL) {
+               printf("allocation failed\n");
+               goto err;
+       }
        rcu_config.v = rv;
 
        if (rte_hash_rcu_qsbr_add(tbl_rwc_test_param.h, &rcu_config) < 0) {
-- 
2.51.0

Reply via email to