patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Yunjian Wang <wangyunjian@huawei.com>
To: <stable@dpdk.org>
Cc: <david.marchand@redhat.com>, <huangshaozhang@huawei.com>,
	Yunjian Wang <wangyunjian@huawei.com>
Subject: [PATCH 19.11] mem: check allocation in dynamic hugepage init
Date: Thu, 3 Mar 2022 17:43:26 +0800	[thread overview]
Message-ID: <505cb50dee6a782d2e1b5ebca4c6431267f65cef.1646117028.git.wangyunjian@huawei.com> (raw)

[ 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


                 reply	other threads:[~2022-03-03  9:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=505cb50dee6a782d2e1b5ebca4c6431267f65cef.1646117028.git.wangyunjian@huawei.com \
    --to=wangyunjian@huawei.com \
    --cc=david.marchand@redhat.com \
    --cc=huangshaozhang@huawei.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).