[dpdk-dev] [PATCH] eal/linux: fix undefined allocation of 0 bytes (CERT MEM04-C; CWE-131)
Daniel Mrzyglod
danielx.t.mrzyglod at intel.com
Wed Apr 27 19:06:04 CEST 2016
Fix issue reported by clang scan-build
there is a chance that nr_hugepages will be 0 if conditions for loop
for (i = 0; i < (int) internal_config.num_hugepage_sizes; i++)
will be unmeet.
Fixes: b6a468ad41d5 ("memory: add --socket-mem option")
Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod at intel.com>
---
lib/librte_eal/linuxapp/eal/eal_memory.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 5b9132c..e94538e 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -1114,6 +1114,8 @@ rte_eal_hugepage_init(void)
* processing done on these pages, shared memory will be created
* at a later stage.
*/
+ if (nr_hugepages == 0)
+ goto fail;
tmp_hp = malloc(nr_hugepages * sizeof(struct hugepage_file));
if (tmp_hp == NULL)
goto fail;
--
2.5.5
More information about the dev
mailing list