patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 19.11] mem: check allocation in dynamic hugepage init
@ 2022-03-03  9:43 Yunjian Wang
  0 siblings, 0 replies; only message in thread
From: Yunjian Wang @ 2022-03-03  9:43 UTC (permalink / raw)
  To: stable; +Cc: david.marchand, huangshaozhang, Yunjian Wang

[ 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@huawei.com>
Reviewed-by: David Marchand <david.marchand@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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-03  9:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-03  9:43 [PATCH 19.11] mem: check allocation in dynamic hugepage init Yunjian Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).