Skip to contentSkip to conversation

eal: fail eal when no hugepages were found

PATCH In review Emmanuel Roullit 2 participants 2 messages Jan 24, 2017 – Jan 29, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal: fail eal when no hugepages were found

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")
---
 lib/librte_eal/linuxapp/eal/eal_memory.c | 3 +++
 1 file changed, 3 insertions(+)
lib/librte_eal/linuxapp/eal/eal_memory.c +3 -0
index a956bb226..0b0355898 100644
@@ -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
Signature · 1 line
2.11.0
#1 lore raw

2017-01-24 21:22, Emmanuel Roullit:

Quoted 10 lines

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")

This commit reference seems wrong. Please check