[PATCH] eventdev: fix dereferencing null atomic locks pointer in test-eventdev
Luka Jankovic
luka.jankovic at ericsson.com
Wed Mar 26 11:09:52 CET 2025
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 at 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
More information about the dev
mailing list