]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/efi: efi_unmap_boot_services: fix calculation of ranges_to_free size
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Fri, 20 Mar 2026 13:59:48 +0000 (15:59 +0200)
committerArd Biesheuvel <ardb@kernel.org>
Fri, 20 Mar 2026 14:31:10 +0000 (15:31 +0100)
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>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
arch/x86/platform/efi/quirks.c

index 35caa5746115d74c61e8090bf04b5880cf2e5d8f..79f0818131e8306651d341c394a2e0df5786d887 100644 (file)
@@ -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");