patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: david.marchand@redhat.com, stable@dpdk.org,
	Yipeng Wang <yipeng1.wang@intel.com>,
	Sameh Gobriel <sameh.gobriel@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Subject: [PATCH 1/2] test/hash: check memory allocation
Date: Thu, 30 Oct 2025 18:50:11 +0100	[thread overview]
Message-ID: <20251030175329.4041960-2-thomas@monjalon.net> (raw)
In-Reply-To: <20251030175329.4041960-1-thomas@monjalon.net>

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: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 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	other threads:[~2025-10-30 17:53 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20251030175329.4041960-1-thomas@monjalon.net>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251030175329.4041960-2-thomas@monjalon.net \
    --to=thomas@monjalon.net \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=sameh.gobriel@intel.com \
    --cc=stable@dpdk.org \
    --cc=vladimir.medvedkin@intel.com \
    --cc=yipeng1.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).