* [PATCH v1 1/1] malloc: handle invalid socket ID's when allocating
@ 2025-06-16 9:55 Anatoly Burakov
0 siblings, 0 replies; only message in thread
From: Anatoly Burakov @ 2025-06-16 9:55 UTC (permalink / raw)
To: dev, Tyler Retzlaff
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-06-16 9:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-16 9:55 [PATCH v1 1/1] malloc: handle invalid socket ID's when allocating Anatoly Burakov
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).