aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShao Miller <sha0.miller@gmail.com>2012-10-30 17:41:09 -0400
committerMatt Fleming <matt.fleming@intel.com>2012-10-31 16:12:53 +0000
commit90be055dcd959eecb0253e6e7a699a074a6f345f (patch)
tree24a45544b818fe6a045b7f9477fb6e2479c513a7
parent40c78259c9d9d668174fc4e93303fd11463a3c31 (diff)
downloadsyslinux-90be055dcd959eecb0253e6e7a699a074a6f345f.tar.gz
syslinux-90be055dcd959eecb0253e6e7a699a074a6f345f.tar.xz
syslinux-90be055dcd959eecb0253e6e7a699a074a6f345f.zip
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@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> [Added changelog]
-rw-r--r--efi/main.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/efi/main.c b/efi/main.c
index e31d529e..07760200 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) {