From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, anatoly.burakov@intel.com
Subject: [dpdk-dev] [PATCH 1/2] eal: fix potential negative return
Date: Tue, 17 Apr 2018 16:42:28 +0100 [thread overview]
Message-ID: <8fc9683d48cddb0615f1f1d4482790f54bd8e317.1523977960.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <cover.1523977960.git.anatoly.burakov@intel.com>
In-Reply-To: <cover.1523977960.git.anatoly.burakov@intel.com>
Value returned by rte_socket_id_by_idx() may be negative, which would
result in negative array index access.
Coverity issue: 272600
Fixes: b666f17858a3 ("mem: read hugepage counts from node-specific sysfs path")
Cc: anatoly.burakov@intel.com
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
lib/librte_eal/linuxapp/eal/eal_hugepage_info.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
index fb4b667..009f963 100644
--- a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
+++ b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
@@ -402,9 +402,16 @@ hugepage_info_init(void)
/* we also don't want to do this for legacy init */
if (!internal_config.legacy_mem)
for (i = 0; i < rte_socket_count(); i++) {
- int socket = rte_socket_id_by_idx(i);
- unsigned int num_pages =
- get_num_hugepages_on_node(
+ int socket;
+ unsigned int num_pages;
+
+ socket = rte_socket_id_by_idx(i);
+ if (socket < 0) {
+ RTE_LOG(ERR, EAL, "Invalid socket index: %u\n",
+ i);
+ continue;
+ }
+ num_pages = get_num_hugepages_on_node(
dirent->d_name, socket);
hpi->num_pages[socket] = num_pages;
total_pages += num_pages;
--
2.7.4
next prev parent reply other threads:[~2018-04-17 15:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-17 15:42 [dpdk-dev] [PATCH 0/2] Coverity fixes for EAL Anatoly Burakov
2018-04-17 15:42 ` Anatoly Burakov [this message]
2018-04-25 5:55 ` [dpdk-dev] [PATCH 1/2] eal: fix potential negative return Tan, Jianfeng
2018-04-17 15:42 ` [dpdk-dev] [PATCH 2/2] eal: fix not checking unlock result Anatoly Burakov
2018-04-25 7:09 ` Tan, Jianfeng
2018-04-25 8:53 ` Burakov, Anatoly
2018-04-25 10:08 ` [dpdk-dev] [PATCH v2] Coverity fixes for EAL Anatoly Burakov
2018-04-25 10:08 ` [dpdk-dev] [PATCH v2] eal: remove call to unlock Anatoly Burakov
2018-04-25 10:32 ` Thomas Monjalon
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=8fc9683d48cddb0615f1f1d4482790f54bd8e317.1523977960.git.anatoly.burakov@intel.com \
--to=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=thomas@monjalon.net \
/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).