[PATCH 2/2] x86/efi: Fix memory leak for EFI memmap reservations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There are some memory leaks in failure path after efi_memmap_alloc().
add efi_memmap_free() for this situation.

Fixes: 816e76129ed5 ("efi: Allow drivers to reserve boot services forever")
Signed-off-by: Yunfeng Ye <yeyunfeng@xxxxxxxxxx>
---
 arch/x86/platform/efi/quirks.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
index 3b9fd67..a755f35 100644
--- a/arch/x86/platform/efi/quirks.c
+++ b/arch/x86/platform/efi/quirks.c
@@ -285,6 +285,7 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size)

 	new = early_memremap(new_phys, new_size);
 	if (!new) {
+		efi_memmap_free(new_phys, num_entries);
 		pr_err("Failed to map new boot services memmap\n");
 		return;
 	}
@@ -470,6 +471,7 @@ void __init efi_free_boot_services(void)

 	new = memremap(new_phys, new_size, MEMREMAP_WB);
 	if (!new) {
+		efi_memmap_free(new_phys, num_entries);
 		pr_err("Failed to map new EFI memmap\n");
 		return;
 	}
@@ -493,6 +495,7 @@ void __init efi_free_boot_services(void)
 	memunmap(new);

 	if (efi_memmap_install(new_phys, num_entries)) {
+		efi_memmap_free(new_phys, num_entries);
 		pr_err("Could not install new EFI memmap\n");
 		return;
 	}
-- 
1.8.3.1




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux