From: Chris Down <chris@chrisdown.name>
To: rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org
Cc: graf@amazon.com, kexec@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: [PATCH] kho: Don't release incoming bootmem areas when kho_init() fails
Date: Sat, 7 Nov 2026 19:40:50 -0800 [thread overview]
Message-ID: <au_vQhHAcJbkryXN@chrisdown.name> (raw)
kho_populate() adds the incoming bootmem areas without reserving
them. memblock_free_all() then hands the remainder to the buddy
allocator.
Unfortunately however, if kho_init() fails, err_free_bootmem
currently frees every area with free_reserved_area(). This can free
pages still backing early allocations or free buddy pages a second
time.
To fix this, let's only free the areas on a cold boot when
kho_reserve_bootmem() reserved them.
Fixes: c609c144b0e8 ("kexec: add KHO parsing support")
Cc: <stable@vger.kernel.org>
Signed-off-by: Chris Down <chris@chrisdown.name>
---
kernel/liveupdate/kexec_handover.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index 6f1f55fe3181..a566ad6634d8 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -1899,11 +1899,13 @@ static __init int kho_init(void)
kho_radix_destroy_tree(tree);
err_free_bootmem:
kho_out.fdt = NULL;
- for (int i = 0; i < kho_bootmem_cnt; i++) {
- void *start = __va(kho_bootmem[i].addr);
- void *end = start + kho_bootmem[i].size;
+ if (!fdt) {
+ for (int i = 0; i < kho_bootmem_cnt; i++) {
+ void *start = __va(kho_bootmem[i].addr);
+ void *end = start + kho_bootmem[i].size;
- free_reserved_area(start, end, -1, "");
+ free_reserved_area(start, end, -1, "");
+ }
}
kho_enable = false;
return err;
base-commit: fa4ad798f6f681031775266044ba1b0cf3c670bd
--
2.54.0
next reply other threads:[~2026-11-08 3:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 3:40 Chris Down [this message]
2026-11-08 14:29 ` [PATCH] kho: Don't release incoming bootmem areas when kho_init() fails Pasha Tatashin
2026-11-09 10:09 ` Mike Rapoport
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=au_vQhHAcJbkryXN@chrisdown.name \
--to=chris@chrisdown.name \
--cc=graf@amazon.com \
--cc=kernel-team@meta.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.