From: Zhou Jianfeng <jianfeng.zhou@intel.com>
To: grub-devel@gnu.org
Cc: Zhou JianFeng <jianfeng.zhou@intel.com>,
daniel.kiper@oracle.com, alexander.burmashev@oracle.com,
phcoder@gmail.com
Subject: [PATCH] efi: mm: Fix incorrect free size
Date: Tue, 23 Apr 2024 09:04:34 +0800 [thread overview]
Message-ID: <20240423010434.21811-1-jianfeng.zhou@intel.com> (raw)
From: Zhou JianFeng <jianfeng.zhou@intel.com>
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.
Cc: daniel.kiper@oracle.com
Cc: alexander.burmashev@oracle.com
Cc: phcoder@gmail.com
Signed-off-by: Zhou JianFeng <jianfeng.zhou@intel.com>
---
grub-core/kern/efi/mm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
index 6a6fba891..49daa976f 100644
--- a/grub-core/kern/efi/mm.c
+++ b/grub-core/kern/efi/mm.c
@@ -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
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
next reply other threads:[~2024-04-23 1:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-23 1:04 Zhou Jianfeng [this message]
2024-05-08 16:34 ` [PATCH] efi: mm: Fix incorrect free size Daniel Kiper via Grub-devel
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=20240423010434.21811-1-jianfeng.zhou@intel.com \
--to=jianfeng.zhou@intel.com \
--cc=alexander.burmashev@oracle.com \
--cc=daniel.kiper@oracle.com \
--cc=grub-devel@gnu.org \
--cc=phcoder@gmail.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).