Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 9aea75b

Browse files
drivers/lpmemmap: comply with UEFI specification
The only situation where GetMemoryMap should return EFI_INVALID_PARAMETER is if MemoryMapSize is NULL. Change-Id: I0d42634c9ee010411baeb2aaf75f713b882f0af8 Signed-off-by: Jeremy Compostella <[email protected]>
1 parent e074c6d commit 9aea75b

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

drivers/lpmemmap/lpmemmap.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ get_memory_map(UINTN *MemoryMapSize, EFI_MEMORY_DESCRIPTOR *MemoryMap,
226226
UINT32 key;
227227
UINTN size;
228228

229-
if (!MemoryMapSize || !MemoryMap || !MapKey ||
230-
!DescriptorSize || !DescriptorVersion)
229+
if (!MemoryMapSize)
231230
return EFI_INVALID_PARAMETER;
232231

233232
if (!efimemmap_nb || !efimemmap)
@@ -239,15 +238,21 @@ get_memory_map(UINTN *MemoryMapSize, EFI_MEMORY_DESCRIPTOR *MemoryMap,
239238
return EFI_BUFFER_TOO_SMALL;
240239
}
241240

242-
ret = uefi_call_wrapper(crc32, 3, efimemmap, size, &key);
243-
if (EFI_ERROR(ret))
244-
return ret;
241+
if (MapKey) {
242+
ret = uefi_call_wrapper(crc32, 3, efimemmap, size, &key);
243+
if (EFI_ERROR(ret))
244+
return ret;
245+
246+
*MapKey = key;
247+
}
245248

246249
*MemoryMapSize = size;
247-
memcpy(MemoryMap, efimemmap, size);
248-
*MapKey = key;
249-
*DescriptorSize = sizeof(*efimemmap);
250-
*DescriptorVersion = EFI_MEMORY_DESCRIPTOR_VERSION;
250+
if (MemoryMap)
251+
memcpy(MemoryMap, efimemmap, size);
252+
if (DescriptorSize)
253+
*DescriptorSize = sizeof(*efimemmap);
254+
if (DescriptorVersion)
255+
*DescriptorVersion = EFI_MEMORY_DESCRIPTOR_VERSION;
251256

252257
return EFI_SUCCESS;
253258
}

0 commit comments

Comments
 (0)