efi: mm: Fix incorrect free size
PATCH 1/1 efi: mm: Fix incorrect free size
From: Zhou JianFeng <[email protected]>
Memory freed by function grub_efi_free_pages() with wrong pages will not be removed from list efi_allocated_memory by function grub_efi_drop_alloc(), it will be freed again by function grub_efi_memory_fini() which is called by function grub_machine_fini()/grub_exit() when exit grub.
Freeing memory twice may lead to unpredictable result.
--- grub-core/kern/efi/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/kern/efi/mm.c +1 -1
@@ -643,7 +643,7 @@ grub_efi_mm_add_regions (grub_size_t required_bytes, unsigned int flags)/* Release the memory maps. */ grub_efi_free_pages ((grub_addr_t ) memory_map, -2 *BYTES_TO_PAGES (MEMORY_MAP_SIZE )); +2 *BYTES_TO_PAGES (map_size));return GRUB_ERR_NONE ; }
--
2.25.1
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Your patch makes sens but the commit message is wrong. In general we will be leaking memory for short time. Not big deal here but worth fixing. The memory will not be freed twice as you say in the commit message. May I ask you to fix the commit message?
Quoted 5 lines · Zhou Jianfeng
From: Zhou JianFeng <[email protected]>
Memory freed by function
grub_efi_free_pages()with wrong pages will not be removed from listefi_allocated_memoryby functiongrub_efi_drop_alloc(), it will be freed again by function
At least "again" should be dropped from here. Though in general this commit message does not parse well and should be rephrased.
Quoted 17 lines
grub_efi_memory_fini()which is called by function grub_machine_fini()/grub_exit() when exit grub. Freeing memory twice may lead to unpredictable result.Signed-off-by Zhou JianFeng <[email protected]>--- grub-core/kern/efi/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)grub-core/kern/efi/mm.c +0
-0
grub-core/kern/efi/mm.c grub_efi_mm_add_regions (grub_size_t required_bytes, unsigned int flags) · line 649
Quoted 8 lines
grub-core/kern/efi/mm.c +1
-1@@ -643,7 +643,7 @@ grub_efi_mm_add_regions (grub_size_t required_bytes, unsigned int flags)/* Release the memory maps. */ grub_efi_free_pages ((grub_addr_t ) memory_map, -2 *BYTES_TO_PAGES (MEMORY_MAP_SIZE )); +2 *BYTES_TO_PAGES (map_size));return GRUB_ERR_NONE ; }
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel