eventdev: fix dereferencing null atomic locks pointer in test-eventdev
PATCH 1/1 eventdev: fix dereferencing null atomic locks pointer in test-eventdev
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
--- 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(-)
app/test-eventdev/test_atomic_atq.c +2 -0
@@ -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 ; }
app/test-eventdev/test_atomic_common.h +3 -1
@@ -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]);
app/test-eventdev/test_atomic_queue.c +2 -0
@@ -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
Quoted 17 lines
-----Original Message-----
From: Luka Jankovic <[email protected]>
Sent: Wednesday, March 26, 2025 3:40 PM
To: [email protected]
Cc: Jerin Jacob <[email protected]>; [email protected]
Subject: [EXTERNAL] [PATCH] eventdev: fix dereferencing null atomic locks pointer in test-eventdevUpdate
atomic_init_locksto 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:
Updateatomic_init_locksto immediately return if memory allocation fails. Atomic queue and atq tests updated to handle atomic locks being null.
Quoted 4 lines
Coverity issue: 457876
Fixes 9d619f82321b ("app/eventdev: introduce atomic tests")Signed-off-by Luka Jankovic <[email protected]>
Please check the git history of the file to know the starting tag.
Updated the git commit as follows and applied to dpdk-next-net-eventdev/for-main. Thanks
app/eventdev: fix dereferencing null
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