DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] eventdev: fix dereferencing null atomic locks pointer in test-eventdev
@ 2025-03-26 10:09 Luka Jankovic
  0 siblings, 0 replies; only message in thread
From: Luka Jankovic @ 2025-03-26 10:09 UTC (permalink / raw)
  To: luka.jankovic; +Cc: jerinj, dev

Update atomic_init_locks to immediately return if memory allocation
fails. Atomic queue and atq tests updated to handle atomic locks being
null.

Coverity issue: 457876
Fixes: 9d619f82321b ("app/eventdev: introduce atomic tests")

Signed-off-by: Luka Jankovic <luka.jankovic@ericsson.com>
---
 app/test-eventdev/test_atomic_atq.c    | 2 ++
 app/test-eventdev/test_atomic_common.h | 4 +++-
 app/test-eventdev/test_atomic_queue.c  | 2 ++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/app/test-eventdev/test_atomic_atq.c b/app/test-eventdev/test_atomic_atq.c
index 4810d2eaae..73e2a53ae4 100644
--- a/app/test-eventdev/test_atomic_atq.c
+++ b/app/test-eventdev/test_atomic_atq.c
@@ -175,6 +175,8 @@ atomic_atq_eventdev_setup(struct evt_test *test, struct evt_options *opt)
 	}

 	atomic_locks = atomic_init_locks(NB_STAGES, opt->nb_flows);
+	if (atomic_locks == NULL)
+		return -1;

 	return 0;
 }
diff --git a/app/test-eventdev/test_atomic_common.h b/app/test-eventdev/test_atomic_common.h
index a3cec4791d..0ee81328a4 100644
--- a/app/test-eventdev/test_atomic_common.h
+++ b/app/test-eventdev/test_atomic_common.h
@@ -66,8 +66,10 @@ atomic_init_locks(uint32_t nb_stages, uint32_t nb_flows)

 	rte_spinlock_t *atomic_locks = rte_calloc(NULL, num_locks, sizeof(rte_spinlock_t), 0);

-	if (atomic_locks == NULL)
+	if (atomic_locks == NULL) {
 		evt_err("Unable to allocate memory for spinlocks.");
+		return NULL;
+	}

 	for (uint32_t i = 0; i < num_locks; i++)
 		rte_spinlock_init(&atomic_locks[i]);
diff --git a/app/test-eventdev/test_atomic_queue.c b/app/test-eventdev/test_atomic_queue.c
index c1a447bbac..8ce0849664 100644
--- a/app/test-eventdev/test_atomic_queue.c
+++ b/app/test-eventdev/test_atomic_queue.c
@@ -189,6 +189,8 @@ atomic_queue_eventdev_setup(struct evt_test *test, struct evt_options *opt)
 	}

 	atomic_locks = atomic_init_locks(NB_STAGES, opt->nb_flows);
+	if (atomic_locks == NULL)
+		return -1;

 	return 0;
 }
--
2.34.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-03-26 10:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-26 10:09 [PATCH] eventdev: fix dereferencing null atomic locks pointer in test-eventdev Luka Jankovic

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