[PATCH 19.11] mem: check allocation in dynamic hugepage init
Yunjian Wang
wangyunjian at huawei.com
Thu Mar 3 10:43:26 CET 2022
[ upstream commit 5f69ebbd85300a197bbe9e6a630642352f5aba39 ]
The function malloc() could return NULL, the return value
need to be checked.
Fixes: 6f63858e55e6 ("mem: prevent preallocated pages from being freed")
Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
Reviewed-by: David Marchand <david.marchand at redhat.com>
---
lib/librte_eal/linux/eal/eal_memory.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/librte_eal/linux/eal/eal_memory.c b/lib/librte_eal/linux/eal/eal_memory.c
index c93d9bb2b8..dc0cdcbe25 100644
--- a/lib/librte_eal/linux/eal/eal_memory.c
+++ b/lib/librte_eal/linux/eal/eal_memory.c
@@ -1818,6 +1818,10 @@ eal_hugepage_init(void)
needed = num_pages - num_pages_alloc;
pages = malloc(sizeof(*pages) * needed);
+ if (pages == NULL) {
+ RTE_LOG(ERR, EAL, "Failed to malloc pages\n");
+ return -1;
+ }
/* do not request exact number of pages */
cur_pages = eal_memalloc_alloc_seg_bulk(pages,
--
2.27.0
More information about the stable
mailing list