From: Yunjian Wang Date: Tue, 14 Dec 2021 13:30:25 +0000 (+0800) Subject: mem: check allocation in dynamic hugepage init X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=5f69ebbd85300a197bbe9e6a630642352f5aba39;p=dpdk.git mem: check allocation in dynamic hugepage init The function malloc() could return NULL, the return value need to be checked. Fixes: 6f63858e55e6 ("mem: prevent preallocated pages from being freed") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang Reviewed-by: David Marchand --- 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,