Use AllocateZeroPool instead of using AllocatePool + ZeroMem
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9495 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
595d4b4c24
commit
0d34b1cfc7
|
@ -358,12 +358,12 @@ SmbiosAdd (
|
||||||
//
|
//
|
||||||
// Allocate internal buffer
|
// Allocate internal buffer
|
||||||
//
|
//
|
||||||
SmbiosEntry = AllocatePool (TotalSize);
|
SmbiosEntry = AllocateZeroPool (TotalSize);
|
||||||
if (SmbiosEntry == NULL) {
|
if (SmbiosEntry == NULL) {
|
||||||
EfiReleaseLock (&Private->DataLock);
|
EfiReleaseLock (&Private->DataLock);
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
HandleEntry = AllocatePool (sizeof(SMBIOS_HANDLE_ENTRY));
|
HandleEntry = AllocateZeroPool (sizeof(SMBIOS_HANDLE_ENTRY));
|
||||||
if (HandleEntry == NULL) {
|
if (HandleEntry == NULL) {
|
||||||
EfiReleaseLock (&Private->DataLock);
|
EfiReleaseLock (&Private->DataLock);
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
@ -372,12 +372,10 @@ SmbiosAdd (
|
||||||
//
|
//
|
||||||
// Build Handle Entry and insert into linked list
|
// Build Handle Entry and insert into linked list
|
||||||
//
|
//
|
||||||
ZeroMem(HandleEntry, sizeof(SMBIOS_HANDLE_ENTRY));
|
|
||||||
HandleEntry->Signature = SMBIOS_HANDLE_ENTRY_SIGNATURE;
|
HandleEntry->Signature = SMBIOS_HANDLE_ENTRY_SIGNATURE;
|
||||||
HandleEntry->SmbiosHandle = *SmbiosHandle;
|
HandleEntry->SmbiosHandle = *SmbiosHandle;
|
||||||
InsertTailList(&Private->AllocatedHandleListHead, &HandleEntry->Link);
|
InsertTailList(&Private->AllocatedHandleListHead, &HandleEntry->Link);
|
||||||
|
|
||||||
ZeroMem (SmbiosEntry, TotalSize);
|
|
||||||
InternalRecord = (EFI_SMBIOS_RECORD_HEADER *) (SmbiosEntry + 1);
|
InternalRecord = (EFI_SMBIOS_RECORD_HEADER *) (SmbiosEntry + 1);
|
||||||
Raw = (VOID *) (InternalRecord + 1);
|
Raw = (VOID *) (InternalRecord + 1);
|
||||||
|
|
||||||
|
@ -528,14 +526,13 @@ SmbiosUpdateString (
|
||||||
// Re-allocate buffer is needed.
|
// Re-allocate buffer is needed.
|
||||||
//
|
//
|
||||||
NewEntrySize = SmbiosEntry->RecordSize + InputStrLen - TargetStrLen;
|
NewEntrySize = SmbiosEntry->RecordSize + InputStrLen - TargetStrLen;
|
||||||
ResizedSmbiosEntry = AllocatePool (NewEntrySize);
|
ResizedSmbiosEntry = AllocateZeroPool (NewEntrySize);
|
||||||
|
|
||||||
if (ResizedSmbiosEntry == NULL) {
|
if (ResizedSmbiosEntry == NULL) {
|
||||||
EfiReleaseLock (&Private->DataLock);
|
EfiReleaseLock (&Private->DataLock);
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroMem (ResizedSmbiosEntry, NewEntrySize);
|
|
||||||
InternalRecord = (EFI_SMBIOS_RECORD_HEADER *) (ResizedSmbiosEntry + 1);
|
InternalRecord = (EFI_SMBIOS_RECORD_HEADER *) (ResizedSmbiosEntry + 1);
|
||||||
Raw = (VOID *) (InternalRecord + 1);
|
Raw = (VOID *) (InternalRecord + 1);
|
||||||
|
|
||||||
|
@ -811,7 +808,7 @@ SmbiosCreateTable (
|
||||||
//
|
//
|
||||||
// Free the original image
|
// Free the original image
|
||||||
//
|
//
|
||||||
if (EntryPointStructure->TableAddress) {
|
if (EntryPointStructure->TableAddress != 0) {
|
||||||
FreePages (
|
FreePages (
|
||||||
(VOID*)(UINTN)EntryPointStructure->TableAddress,
|
(VOID*)(UINTN)EntryPointStructure->TableAddress,
|
||||||
EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength)
|
EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength)
|
||||||
|
@ -822,8 +819,8 @@ SmbiosCreateTable (
|
||||||
//
|
//
|
||||||
// Locate smbios protocol to traverse smbios records.
|
// Locate smbios protocol to traverse smbios records.
|
||||||
//
|
//
|
||||||
gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **) &SmbiosProtocol);
|
Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **) &SmbiosProtocol);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
ASSERT (SmbiosProtocol != NULL);
|
ASSERT (SmbiosProtocol != NULL);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -851,7 +848,7 @@ SmbiosCreateTable (
|
||||||
//
|
//
|
||||||
// Record NumberOfSmbiosStructures, TableLength and MaxStructureSize
|
// Record NumberOfSmbiosStructures, TableLength and MaxStructureSize
|
||||||
//
|
//
|
||||||
EntryPointStructure->NumberOfSmbiosStructures++;
|
EntryPointStructure->NumberOfSmbiosStructures ++;
|
||||||
EntryPointStructure->TableLength = (UINT16) (EntryPointStructure->TableLength + RecordSize);
|
EntryPointStructure->TableLength = (UINT16) (EntryPointStructure->TableLength + RecordSize);
|
||||||
if (RecordSize > EntryPointStructure->MaxStructureSize) {
|
if (RecordSize > EntryPointStructure->MaxStructureSize) {
|
||||||
EntryPointStructure->MaxStructureSize = (UINT16) RecordSize;
|
EntryPointStructure->MaxStructureSize = (UINT16) RecordSize;
|
||||||
|
|
Loading…
Reference in New Issue