[tip: x86/mm] x86/mm: Fix spurious warning on __add_pages() failure

From: tip-bot2 for Lance Yang

Date: Thu Oct 01 2026 - 08:17:20 EST


The following commit has been merged into the x86/mm branch of tip:

Commit-ID: d92b5ac5aeba1ffc734576e30a5bca882722de76
Gitweb: https://git.kernel.org/tip/d92b5ac5aeba1ffc734576e30a5bca882722de76
Author: Lance Yang <lance.yang@xxxxxxxxx>
AuthorDate: Thu, 01 Oct 2026 16:15:55 +08:00
Committer: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
CommitterDate: Thu, 01 Oct 2026 05:04:44 -07:00

x86/mm: Fix spurious warning on __add_pages() failure

__add_pages() can fail if we run out of memory. Callers already handle
that. Do not WARN_ON_ONCE() just because an allocation failed.

Return the error instead, and only update the end-of-memory variables
after __add_pages() succeeds.

[ dhansen: imperative voice changelog fixups ]

Fixes: 10f22dde556d ("x86: arch/x86/mm/init_64.c printk fixes")
Reported-by: David Hildenbrand <david@xxxxxxxxxx>
Suggested-by: Muchun Song <muchun.song@xxxxxxxxx>
Signed-off-by: Lance Yang <lance.yang@xxxxxxxxx>
Signed-off-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Reviewed-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Acked-by: Muchun Song <muchun.song@xxxxxxxxx>
Link: https://lore.kernel.org/all/d4fac8af-fd71-47a2-bfe9-3c6559b92209@xxxxxxxxxx/
Link: https://lore.kernel.org/all/203892F4-B04A-4F69-A1B3-DC1619176C67@xxxxxxxxx/
Link: https://patch.msgid.link/20261001081555.35485-1-lance.yang@xxxxxxxxx
---
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 70e6821..8b6d86f 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