[syslinux:firmware] efi: Fix a memory map buffer release

syslinux-bot for Shao Miller sha0.miller at gmail.com
Fri Nov 9 09:06:33 PST 2012


Commit-ID:  90be055dcd959eecb0253e6e7a699a074a6f345f
Gitweb:     http://www.syslinux.org/commit/90be055dcd959eecb0253e6e7a699a074a6f345f
Author:     Shao Miller <sha0.miller at gmail.com>
AuthorDate: Tue, 30 Oct 2012 17:41:09 -0400
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Wed, 31 Oct 2012 16:12:53 +0000

efi: Fix a memory map buffer release

We need to track the beginning of the memory map buffer so that we
free the correct pointer at the end of efi_scan_memory(). Previously
we were passing a pointer that pointed after the memory map, resulting
in a crash when running syslinux.efi under DUET.

Signed-off-by: Shao Miller <sha0.miller at gmail.com>
Signed-off-by: Matt Fleming <matt.fleming at intel.com> [Added changelog]

---
 efi/main.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/efi/main.c b/efi/main.c
index e31d529..0776020 100644
--- a/efi/main.c
+++ b/efi/main.c
@@ -195,7 +195,7 @@ get_memory_map(UINTN *nr_entries, UINTN *key, UINTN *desc_sz,
 int efi_scan_memory(scan_memory_callback_t callback, void *data)
 {
 	UINTN nr_entries, key, desc_sz;
-	UINTN buf;
+	UINTN buf, bufpos;
 	UINT32 desc_ver;
 	int rv = 0;
 	int i;
@@ -203,13 +203,14 @@ int efi_scan_memory(scan_memory_callback_t callback, void *data)
 	buf = (UINTN)get_memory_map(&nr_entries, &key, &desc_sz, &desc_ver);
 	if (!buf)
 		return -1;
+	bufpos = buf;
 
-	for (i = 0; i < nr_entries; buf += desc_sz, i++) {
+	for (i = 0; i < nr_entries; bufpos += desc_sz, i++) {
 		EFI_MEMORY_DESCRIPTOR *m;
 		UINT64 region_sz;
 		int valid;
 
-		m = (EFI_MEMORY_DESCRIPTOR *)buf;
+		m = (EFI_MEMORY_DESCRIPTOR *)bufpos;
 		region_sz = m->NumberOfPages * EFI_PAGE_SIZE;
 
 		switch (m->Type) {


More information about the Syslinux-commits mailing list