From: Liam Ni <zhiguangni01@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
rppt@kernel.org, Liam Ni <zhiguangni01@gmail.com>
Subject: [PATCH] mm/sparse: Check the return value of first_present_section_nr()
Date: Mon, 19 Jun 2023 12:44:03 +0800 [thread overview]
Message-ID: <20230619044403.1519685-1-zhiguangni01@gmail.com> (raw)
first_present_section_nr() may return -1,
which means there is no present section in system,or other errors,
so we cause panic here.
Signed-off-by: Liam Ni <zhiguangni01@gmail.com>
---
mm/sparse.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/sparse.c b/mm/sparse.c
index b8d5d58fe240..175727e10deb 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -564,6 +564,8 @@ void __init sparse_init(void)
memblocks_present();
pnum_begin = first_present_section_nr();
+ if (pnum_begin == -1)
+ panic("There is no present section in system\n");
nid_begin = sparse_early_nid(__nr_to_section(pnum_begin));
/* Setup pageblock_order for HUGETLB_PAGE_SIZE_VARIABLE */
--
2.25.1
next reply other threads:[~2023-06-19 4:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-19 4:44 Liam Ni [this message]
2023-06-19 8:41 ` David Hildenbrand
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=20230619044403.1519685-1-zhiguangni01@gmail.com \
--to=zhiguangni01@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rppt@kernel.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