From: Emmanuel Roullit <emmanuel.roullit@gmail.com>
To: david.marchand@6wind.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] eal: fail eal when no hugepages were found
Date: Tue, 24 Jan 2017 21:22:02 +0100 [thread overview]
Message-ID: <20170124202202.31045-1-emmanuel.roullit@gmail.com> (raw)
Found with clang static analysis:
lib/librte_eal/linuxapp/eal/eal_memory.c:1004:11:
warning: Call to 'malloc' has an allocation size of 0 bytes
tmp_hp = malloc(nr_hugepages * sizeof(struct hugepage_file));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The --no-huge case, where nr_hugepages would be 0
as well, is handled earlier.
Fixes: 5e823a451261 ("ethdev: remove some VF functions")
Signed-off-by: Emmanuel Roullit <emmanuel.roullit@gmail.com>
---
lib/librte_eal/linuxapp/eal/eal_memory.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index a956bb226..0b0355898 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -995,6 +995,9 @@ rte_eal_hugepage_init(void)
nr_hugepages += internal_config.hugepage_info[i].num_pages[0];
}
+ if (nr_hugepages == 0)
+ goto fail;
+
/*
* allocate a memory area for hugepage table.
* this isn't shared memory yet. due to the fact that we need some
--
2.11.0
next reply other threads:[~2017-01-24 20:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-24 20:22 Emmanuel Roullit [this message]
2017-01-29 22:08 ` 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=20170124202202.31045-1-emmanuel.roullit@gmail.com \
--to=emmanuel.roullit@gmail.com \
--cc=david.marchand@6wind.com \
--cc=dev@dpdk.org \
/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).