From: Lance Yang <lance.yang@linux.dev>
To: dave.hansen@linux.intel.com
Cc: luto@kernel.org, peterz@infradead.org, tglx@kernel.org,
mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
david@kernel.org, muchun.song@linux.dev,
Lance Yang <lance.yang@linux.dev>
Subject: [PATCH 1/1] x86/mm: fix spurious warning on __add_pages() failure
Date: Thu, 1 Oct 2026 16:15:55 +0800 [thread overview]
Message-ID: <20261001081555.35485-1-lance.yang@linux.dev> (raw)
__add_pages() can fail if we run out of memory. The caller already
handles that, so we shouldn't WARN_ON_ONCE() just because an allocation
failed.
Let's return the error instead, and only update the end-of-memory
variables after __add_pages() succeeds.
Fixes: 10f22dde556d ("x86: arch/x86/mm/init_64.c printk fixes")
Reported-by: David Hildenbrand <david@kernel.org>
Link: https://lore.kernel.org/all/d4fac8af-fd71-47a2-bfe9-3c6559b92209@kernel.org/
Suggested-by: Muchun Song <muchun.song@linux.dev>
Link: https://lore.kernel.org/all/203892F4-B04A-4F69-A1B3-DC1619176C67@linux.dev/
Signed-off-by: Lance Yang <lance.yang@linux.dev>
---
arch/x86/mm/init_64.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 70e682180291a..8b6d86fb5a42e 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -970,7 +970,8 @@ int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,
return -ERANGE;
ret = __add_pages(nid, start_pfn, nr_pages, params);
- WARN_ON_ONCE(ret);
+ if (ret)
+ return ret;
/*
* Special case: add_pages() is called by memremap_pages() for adding device
--
2.49.0
next reply other threads:[~2026-10-01 8:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 8:15 Lance Yang [this message]
2026-10-01 9:12 ` Muchun Song
2026-10-01 9:43 ` David Hildenbrand (Arm)
2026-10-01 12:08 ` [tip: x86/mm] x86/mm: Fix " tip-bot2 for Lance Yang
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=20261001081555.35485-1-lance.yang@linux.dev \
--to=lance.yang@linux.dev \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=david@kernel.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=muchun.song@linux.dev \
--cc=peterz@infradead.org \
--cc=tglx@kernel.org \
--cc=x86@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
all inboxes | Powered by JetHome®