From: Mike Rapoport <rppt@kernel.org>
To: Guenter Roeck <linux@roeck-us.net>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
Ard Biesheuvel <ardb@kernel.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@kernel.org>,
linux-efi@vger.kernel.org, linux-mm@kvack.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] x86/efi: defer freeing of boot services memory
Date: Fri, 20 Mar 2026 16:08:39 +0200 [thread overview]
Message-ID: <ab1U59ye2eBOz6x3@kernel.org> (raw)
In-Reply-To: <100b9ae1-74cc-48b3-ba63-1a72cfa2ebbd@roeck-us.net>
On Thu, Mar 19, 2026 at 09:06:52PM -0700, Guenter Roeck wrote:
> Hi,
>
> > +void __init efi_unmap_boot_services(void)
> > {
> > struct efi_memory_map_data data = { 0 };
> > efi_memory_desc_t *md;
> > int num_entries = 0;
> > + int idx = 0;
> > + size_t sz;
> > void *new, *new_md;
> >
> > /* Keep all regions for /sys/kernel/debug/efi */
> > if (efi_enabled(EFI_DBG))
> > return;
> >
> > + sz = sizeof(*ranges_to_free) * efi.memmap.nr_map + 1;
>
> Was this possibly supposed to be
> sz = sizeof(*ranges_to_free) * (efi.memmap.nr_map + 1);
> ^ ^
> ?
Yes, thanks for catching this.
@Ard, can you please pick the fix:
From 8fc5c5e828e7d127e6210bc9952451300591cdce Mon Sep 17 00:00:00 2001
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
Date: Fri, 20 Mar 2026 15:59:48 +0200
Subject: [PATCH] x86/efi: efi_unmap_boot_services: fix calculation of
ranges_to_free size
ranges_to_free array should have enough room to store the entire EFI
memmap plus an extra element for NULL entry.
The calculation of this array size wrongly adds 1 to the overall size
instead of adding 1 to the number of elements.
Add parentheses to properly size the array.
Reported-by: Guenter Roeck <linux@roeck-us.net>
Fixes: a4b0bf6a40f3 ("x86/efi: defer freeing of boot services memory")
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
arch/x86/platform/efi/quirks.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
index 35caa5746115..79f0818131e8 100644
--- a/arch/x86/platform/efi/quirks.c
+++ b/arch/x86/platform/efi/quirks.c
@@ -424,7 +424,7 @@ void __init efi_unmap_boot_services(void)
if (efi_enabled(EFI_DBG))
return;
- sz = sizeof(*ranges_to_free) * efi.memmap.nr_map + 1;
+ sz = sizeof(*ranges_to_free) * (efi.memmap.nr_map + 1);
ranges_to_free = kzalloc(sz, GFP_KERNEL);
if (!ranges_to_free) {
pr_err("Failed to allocate storage for freeable EFI regions\n");
--
2.53.0
next prev parent reply other threads:[~2026-03-20 14:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 6:55 [PATCH v2] x86/efi: defer freeing of boot services memory Mike Rapoport
2026-03-04 8:17 ` Mike Rapoport
2026-03-04 17:44 ` Dave Hansen
2026-03-04 17:45 ` Ard Biesheuvel
2026-03-05 11:11 ` Ard Biesheuvel
2026-03-06 15:54 ` Mike Rapoport
2026-03-06 15:55 ` Ard Biesheuvel
2026-03-20 4:06 ` Guenter Roeck
2026-03-20 14:08 ` Mike Rapoport [this message]
2026-03-20 14:31 ` Ard Biesheuvel
2026-03-20 14:53 ` Guenter Roeck
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=ab1U59ye2eBOz6x3@kernel.org \
--to=rppt@kernel.org \
--cc=ardb@kernel.org \
--cc=benh@kernel.crashing.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=ilias.apalodimas@linaro.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@roeck-us.net \
--cc=mingo@redhat.com \
--cc=stable@vger.kernel.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