patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/1] mem: check allocation in dynamic hugepage init
@ 2021-12-14 13:30 Yunjian Wang
  2022-02-05 17:29 ` David Marchand
  0 siblings, 1 reply; 3+ messages in thread
From: Yunjian Wang @ 2021-12-14 13:30 UTC (permalink / raw)
  To: dev; +Cc: anatoly.burakov, dingxiaoxiong, xudingke, Yunjian Wang, stable

The function malloc() could return NULL, the return value
need to be checked.

Fixes: 694161b7e065 ("mem: extract common dynamic memory allocation")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-11  7:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 13:30 [dpdk-dev] [PATCH 1/1] mem: check allocation in dynamic hugepage init Yunjian Wang
2022-02-05 17:29 ` David Marchand
2022-02-11  7:55   ` David Marchand

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