[dpdk-dev] [PATCH 1/1] mem: check allocation in dynamic hugepage init
Yunjian Wang
wangyunjian at huawei.com
Tue Dec 14 14:30:25 CET 2021
The function malloc() could return NULL, the return value
need to be checked.
Fixes: 694161b7e065 ("mem: extract common dynamic memory allocation")
Cc: stable at dpdk.org
Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
---
lib/eal/common/eal_common_dynmem.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/eal/common/eal_common_dynmem.c b/lib/eal/common/eal_common_dynmem.c
index 7c5437ddfa..c1e1889f5c 100644
--- a/lib/eal/common/eal_common_dynmem.c
+++ b/lib/eal/common/eal_common_dynmem.c
@@ -304,6 +304,10 @@ eal_dynmem_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 dev
mailing list