From: Luka Jankovic <luka.jankovic@ericsson.com>
To: <luka.jankovic@ericsson.com>
Cc: <jerinj@marvell.com>, <dev@dpdk.org>
Subject: [PATCH] eventdev: fix dereferencing null atomic locks pointer in test-eventdev
Date: Wed, 26 Mar 2025 11:09:52 +0100 [thread overview]
Message-ID: <20250326100952.114143-1-luka.jankovic@ericsson.com> (raw)
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
reply other threads:[~2025-03-26 10:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250326100952.114143-1-luka.jankovic@ericsson.com \
--to=luka.jankovic@ericsson.com \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.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).