From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org, Tyler Retzlaff <roretzla@linux.microsoft.com>
Subject: [PATCH v1 1/1] malloc: handle invalid socket ID's when allocating
Date: Mon, 16 Jun 2025 10:55:48 +0100 [thread overview]
Message-ID: <02ee77dec888cd2ece830f63c5163c4ad7d3d3a5.1750067739.git.anatoly.burakov@intel.com> (raw)
This issue was reported by static analysis. It is a false positive,
because both `rte_socket_count` and `rte_socket_id_by_idx` only report
information about physical sockets (so return value of -1 cannot happen,
as we only get into this function when socket ID parameter is -1, which
excludes external memory from consideration), but to avoid future false
positives, we can fix it here.
Coverity issue: 470137
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
lib/eal/common/malloc_heap.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c
index f87a947a42..13a56e490e 100644
--- a/lib/eal/common/malloc_heap.c
+++ b/lib/eal/common/malloc_heap.c
@@ -710,8 +710,9 @@ malloc_get_numa_socket(void)
/* for control threads, return first socket where memory is available */
for (idx = 0; idx < rte_socket_count(); idx++) {
- socket_id = rte_socket_id_by_idx(idx);
- if (conf->numa_mem[socket_id] != 0)
+ int ret = rte_socket_id_by_idx(idx);
+ socket_id = (unsigned int)ret;
+ if (ret != -1 && conf->numa_mem[socket_id] != 0)
return socket_id;
}
/* We couldn't quickly find a NUMA node where memory was available,
--
2.47.1
reply other threads:[~2025-06-16 9:55 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=02ee77dec888cd2ece830f63c5163c4ad7d3d3a5.1750067739.git.anatoly.burakov@intel.com \
--to=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=roretzla@linux.microsoft.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).