Skip to contentSkip to conversation

eventdev: fix dereferencing null atomic locks pointer in test-eventdev

PATCH In review Luka Jankovic 2 participants 2 messages Mar 26, 2025 – Apr 1, 2025

lore
Share & tools
lore
#0 lore raw

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

Fixes 9d619f82321b ("app/eventdev: introduce atomic tests")
---
 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
index 4810d2eaae..73e2a53ae4 100644
@@ -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
index a3cec4791d..0ee81328a4 100644
@@ -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
index c1a447bbac..8ce0849664 100644
@@ -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

#1 lore raw
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-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 Fixes: 9d619f82321b ("app/eventdev: introduce atomic tests") Signed-off-by:
Update atomic_init_locks to 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")

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

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