1. Use MemoryAllocationLib to replace boot services memory services functions in EdkModulePkg.

2. Added NULL pointer check before calling FreePool () to fix bugs when free memory.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2513 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff
2007-03-29 06:58:38 +00:00
parent cb360b2656
commit c8dd259d61
13 changed files with 357 additions and 394 deletions

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006 - 2007, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -576,8 +576,8 @@ Returns:
// //
// Allocate the buffer to return // Allocate the buffer to return
// //
Status = gBS->AllocatePool (EfiBootServicesData, BufferSize, &Buffer); Buffer = AllocatePool (BufferSize);
if (EFI_ERROR (Status)) { if (Buffer == NULL) {
return NULL; return NULL;
} }
// //
@ -591,7 +591,7 @@ Returns:
Buffer Buffer
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->FreePool (Buffer); FreePool (Buffer);
Buffer = NULL; Buffer = NULL;
} }
} }
@ -658,7 +658,7 @@ Returns:
while (DevicePathInst) { while (DevicePathInst) {
if (CompareMem (Single, DevicePathInst, Size) == 0) { if (CompareMem (Single, DevicePathInst, Size) == 0) {
if (!Delete) { if (!Delete) {
gBS->FreePool (DevicePathInst); FreePool (DevicePathInst);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} else { } else {
@ -667,12 +667,14 @@ Returns:
TempDevicePath1, TempDevicePath1,
DevicePathInst DevicePathInst
); );
gBS->FreePool (TempDevicePath1); if (TempDevicePath1 != NULL) {
FreePool (TempDevicePath1);
}
TempDevicePath1 = TempDevicePath2; TempDevicePath1 = TempDevicePath2;
} }
} }
gBS->FreePool (DevicePathInst); FreePool (DevicePathInst);
DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size); DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);
} }
@ -730,7 +732,9 @@ Returns:
// //
// The device path is already in the variable // The device path is already in the variable
// //
gBS->FreePool (VariableDevicePath); if (VariableDevicePath != NULL) {
FreePool (VariableDevicePath);
}
return Status; return Status;
} }
@ -760,7 +764,9 @@ Returns:
); );
} }
gBS->FreePool (VariableDevicePath); if (VariableDevicePath != NULL) {
FreePool (VariableDevicePath);
}
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
@ -774,7 +780,7 @@ Returns:
NewVariableDevicePath NewVariableDevicePath
); );
gBS->FreePool (NewVariableDevicePath); FreePool (NewVariableDevicePath);
return Status; return Status;
} }

View File

@ -46,6 +46,9 @@
<LibraryClass Usage="ALWAYS_CONSUMED"> <LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DevicePathLib</Keyword> <Keyword>DevicePathLib</Keyword>
</LibraryClass> </LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>MemoryAllocationLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions> </LibraryClassDefinitions>
<SourceFiles> <SourceFiles>
<Filename>ConPlatform.c</Filename> <Filename>ConPlatform.c</Filename>

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006 - 2007, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -76,7 +76,7 @@ Returns:
// //
// Free The Old Stack // Free The Old Stack
// //
gBS->FreePool (mBooleanEvaluationStack); FreePool (mBooleanEvaluationStack);
} }
mBooleanEvaluationStack = NewStack; mBooleanEvaluationStack = NewStack;
@ -201,7 +201,7 @@ GrowBooleanExpression (
// //
// Free The Old buffer // Free The Old buffer
// //
gBS->FreePool (*BooleanExpression); FreePool (*BooleanExpression);
} else { } else {
// //
// Copy data into new buffer // Copy data into new buffer
@ -498,7 +498,7 @@ Returns:
MapValue = (UINT8) *MapBuffer; MapValue = (UINT8) *MapBuffer;
} }
gBS->FreePool (MapBuffer); FreePool (MapBuffer);
} }
if (MapBuffer2 != NULL) { if (MapBuffer2 != NULL) {
@ -508,7 +508,7 @@ Returns:
MapValue2 = (UINT8) *MapBuffer2; MapValue2 = (UINT8) *MapBuffer2;
} }
gBS->FreePool (MapBuffer2); FreePool (MapBuffer2);
} }
} }
@ -741,7 +741,7 @@ Returns:
MapValue = (UINT8) *MapBuffer; MapValue = (UINT8) *MapBuffer;
} }
gBS->FreePool (MapBuffer); FreePool (MapBuffer);
} }
if (MapBuffer2 != NULL) { if (MapBuffer2 != NULL) {
@ -751,7 +751,7 @@ Returns:
MapValue2 = (UINT8) *MapBuffer2; MapValue2 = (UINT8) *MapBuffer2;
} }
gBS->FreePool (MapBuffer2); FreePool (MapBuffer2);
} }
} }
@ -913,7 +913,7 @@ Returns:
MapValue = (UINT8) *MapBuffer; MapValue = (UINT8) *MapBuffer;
} }
gBS->FreePool (MapBuffer); FreePool (MapBuffer);
} }
if (MapBuffer2 != NULL) { if (MapBuffer2 != NULL) {
@ -923,7 +923,7 @@ Returns:
MapValue2 = (UINT8) *MapBuffer2; MapValue2 = (UINT8) *MapBuffer2;
} }
gBS->FreePool (MapBuffer2); FreePool (MapBuffer2);
} }
} }
@ -1049,7 +1049,7 @@ Returns:
MapValue = (UINT8) *MapBuffer; MapValue = (UINT8) *MapBuffer;
} }
gBS->FreePool (MapBuffer); FreePool (MapBuffer);
} }
if (MapBuffer2 != NULL) { if (MapBuffer2 != NULL) {
@ -1059,7 +1059,7 @@ Returns:
MapValue2 = (UINT8) *MapBuffer2; MapValue2 = (UINT8) *MapBuffer2;
} }
gBS->FreePool (MapBuffer2); FreePool (MapBuffer2);
} }
} }
@ -1205,7 +1205,7 @@ Returns:
MapValue = (UINT8) *MapBuffer; MapValue = (UINT8) *MapBuffer;
} }
gBS->FreePool (MapBuffer); FreePool (MapBuffer);
} }
if (MapBuffer2 != NULL) { if (MapBuffer2 != NULL) {
@ -1215,7 +1215,7 @@ Returns:
MapValue2 = (UINT8) *MapBuffer2; MapValue2 = (UINT8) *MapBuffer2;
} }
gBS->FreePool (MapBuffer2); FreePool (MapBuffer2);
} }
} }

View File

@ -86,7 +86,7 @@ ReadString(
// //
CreatePopUp (ScreenSize, 4, &NullCharacter, PromptForDataString, Space, &NullCharacter); CreatePopUp (ScreenSize, 4, &NullCharacter, PromptForDataString, Space, &NullCharacter);
gBS->FreePool (PromptForDataString); FreePool (PromptForDataString);
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_BLACK, EFI_LIGHTGRAY)); gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_BLACK, EFI_LIGHTGRAY));
@ -107,8 +107,8 @@ ReadString(
break; break;
case SCAN_ESC: case SCAN_ESC:
gBS->FreePool (TempString); FreePool (TempString);
gBS->FreePool (BufferedString); FreePool (BufferedString);
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
gST->ConOut->EnableCursor (gST->ConOut, CursorVisible); gST->ConOut->EnableCursor (gST->ConOut, CursorVisible);
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
@ -122,8 +122,8 @@ ReadString(
case CHAR_CARRIAGE_RETURN: case CHAR_CARRIAGE_RETURN:
if (GetStringWidth (StringPtr) >= MenuOption->ThisTag->Minimum) { if (GetStringWidth (StringPtr) >= MenuOption->ThisTag->Minimum) {
SelectionComplete = TRUE; SelectionComplete = TRUE;
gBS->FreePool (TempString); FreePool (TempString);
gBS->FreePool (BufferedString); FreePool (BufferedString);
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
gST->ConOut->EnableCursor (gST->ConOut, CursorVisible); gST->ConOut->EnableCursor (gST->ConOut, CursorVisible);
return EFI_SUCCESS; return EFI_SUCCESS;
@ -137,8 +137,8 @@ ReadString(
do { do {
Status = WaitForKeyStroke (&Key); Status = WaitForKeyStroke (&Key);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN); } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
gBS->FreePool (TempString); FreePool (TempString);
gBS->FreePool (BufferedString); FreePool (BufferedString);
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
gST->ConOut->EnableCursor (gST->ConOut, CursorVisible); gST->ConOut->EnableCursor (gST->ConOut, CursorVisible);
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
@ -309,7 +309,7 @@ Error:
WidthOfString = GetStringWidth (Packet->String); WidthOfString = GetStringWidth (Packet->String);
ScreenSize = EFI_MAX(WidthOfString, GetStringWidth (gPressEnter)) / 2; ScreenSize = EFI_MAX(WidthOfString, GetStringWidth (gPressEnter)) / 2;
CreatePopUp (ScreenSize, 4, &NullCharacter, Packet->String, gPressEnter, &NullCharacter); CreatePopUp (ScreenSize, 4, &NullCharacter, Packet->String, gPressEnter, &NullCharacter);
gBS->FreePool (Packet); FreePool (Packet);
do { do {
Status = WaitForKeyStroke (&Key); Status = WaitForKeyStroke (&Key);
@ -422,7 +422,7 @@ Error:
WidthOfString = GetStringWidth (Packet->String); WidthOfString = GetStringWidth (Packet->String);
ScreenSize = EFI_MAX (WidthOfString, GetStringWidth (gPressEnter)) / 2; ScreenSize = EFI_MAX (WidthOfString, GetStringWidth (gPressEnter)) / 2;
CreatePopUp (ScreenSize, 4, &NullCharacter, Packet->String, gPressEnter, &NullCharacter); CreatePopUp (ScreenSize, 4, &NullCharacter, Packet->String, gPressEnter, &NullCharacter);
gBS->FreePool (Packet); FreePool (Packet);
} }
StringPtr[0] = CHAR_NULL; StringPtr[0] = CHAR_NULL;
@ -571,8 +571,8 @@ Error:
} while (1); } while (1);
Done: Done:
gBS->FreePool (TempString); FreePool (TempString);
gBS->FreePool (TempString2); FreePool (TempString2);
return Status; return Status;
} }
@ -600,7 +600,7 @@ EncodePassword (
CopyMem (Password, Buffer, MaxSize); CopyMem (Password, Buffer, MaxSize);
gBS->FreePool (Buffer); FreePool (Buffer);
return ; return ;
} }
@ -880,7 +880,7 @@ EnterCarriageReturn:
case CHAR_CARRIAGE_RETURN: case CHAR_CARRIAGE_RETURN:
SelectionComplete = TRUE; SelectionComplete = TRUE;
gBS->FreePool (StringPtr); FreePool (StringPtr);
break; break;
default: default:
@ -1083,7 +1083,7 @@ GetSelectionInputPopUp (
PopUpWidth = StrLen (StringPtr); PopUpWidth = StrLen (StringPtr);
} }
gBS->FreePool (StringPtr); FreePool (StringPtr);
} }
} }
// //
@ -1224,7 +1224,7 @@ GetSelectionInputPopUp (
TempStringPtr = AllocateZeroPool (sizeof (CHAR16) * (PopUpWidth - 1)); TempStringPtr = AllocateZeroPool (sizeof (CHAR16) * (PopUpWidth - 1));
ASSERT (TempStringPtr != NULL); ASSERT (TempStringPtr != NULL);
CopyMem (TempStringPtr, StringPtr, (sizeof (CHAR16) * (PopUpWidth - 5))); CopyMem (TempStringPtr, StringPtr, (sizeof (CHAR16) * (PopUpWidth - 5)));
gBS->FreePool (StringPtr); FreePool (StringPtr);
StringPtr = TempStringPtr; StringPtr = TempStringPtr;
StrCat (StringPtr, (CHAR16 *) L"..."); StrCat (StringPtr, (CHAR16 *) L"...");
} }
@ -1256,7 +1256,7 @@ GetSelectionInputPopUp (
PrintStringAt (Start + 2, Index2, StringPtr); PrintStringAt (Start + 2, Index2, StringPtr);
} }
gBS->FreePool (StringPtr); FreePool (StringPtr);
Index2 = Index2 + 1; Index2 = Index2 + 1;
} }
} }
@ -1520,7 +1520,7 @@ TheKey:
case SCAN_ESC: case SCAN_ESC:
gST->ConOut->SetAttribute (gST->ConOut, SavedAttribute); gST->ConOut->SetAttribute (gST->ConOut, SavedAttribute);
if (ValueArrayBackup != NULL) { if (ValueArrayBackup != NULL) {
gBS->FreePool (ValueArrayBackup); FreePool (ValueArrayBackup);
} }
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
@ -1537,7 +1537,7 @@ TheKey:
// //
if (Tag->Operand == EFI_IFR_ORDERED_LIST_OP) { if (Tag->Operand == EFI_IFR_ORDERED_LIST_OP) {
CopyMem (ValueArray, ValueArrayBackup, ValueCount); CopyMem (ValueArray, ValueArrayBackup, ValueCount);
gBS->FreePool (ValueArrayBackup); FreePool (ValueArrayBackup);
} else { } else {
*Value = TempValue; *Value = TempValue;
} }

View File

@ -1,5 +1,5 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006 - 2007, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -60,7 +60,7 @@ ClearLines (
gST->ConOut->SetCursorPosition (gST->ConOut, LeftColumn, TopRow); gST->ConOut->SetCursorPosition (gST->ConOut, LeftColumn, TopRow);
gBS->FreePool (Buffer); FreePool (Buffer);
return ; return ;
} }
@ -237,7 +237,7 @@ DisplayPageFrame (
break; break;
} }
gBS->FreePool (StrFrontPageBanner); FreePool (StrFrontPageBanner);
} }
} }
} }
@ -318,7 +318,7 @@ DisplayPageFrame (
} }
} }
gBS->FreePool (Buffer); FreePool (Buffer);
} }
@ -437,7 +437,7 @@ DisplayForm (
// //
// Remove Buffer allocated for StringPtr after it has been used. // Remove Buffer allocated for StringPtr after it has been used.
// //
gBS->FreePool (StringPtr); FreePool (StringPtr);
for (Index = 0; FormTags.Tags[Index].Operand != EFI_IFR_END_FORM_OP; Index++) { for (Index = 0; FormTags.Tags[Index].Operand != EFI_IFR_END_FORM_OP; Index++) {
GrayOut = FALSE; GrayOut = FALSE;
@ -595,7 +595,7 @@ GetOut:
FormTags.Tags[Index].NumberOfLines++; FormTags.Tags[Index].NumberOfLines++;
} }
gBS->FreePool (OutputString); FreePool (OutputString);
} }
ArrayEntry = 0; ArrayEntry = 0;
@ -1212,7 +1212,7 @@ Returns:
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->FreePool (LocalTags->Tags); FreePool (LocalTags->Tags);
return ; return ;
} }
@ -1317,7 +1317,7 @@ Returns:
} }
if (Packet != NULL) { if (Packet != NULL) {
gBS->FreePool (Packet); FreePool (Packet);
} }
for (BackupIndex = 0; LocalTags->Tags[BackupIndex].Operand != EFI_IFR_END_FORM_OP; BackupIndex++) { for (BackupIndex = 0; LocalTags->Tags[BackupIndex].Operand != EFI_IFR_END_FORM_OP; BackupIndex++) {
@ -1347,7 +1347,7 @@ Returns:
// Delete the buffer associated with previous dynamic page // Delete the buffer associated with previous dynamic page
// We will re-allocate a buffer.... // We will re-allocate a buffer....
// //
gBS->FreePool (LocalTags->Tags); FreePool (LocalTags->Tags);
Length = 0xF000; Length = 0xF000;
Buffer = AllocateZeroPool (Length); Buffer = AllocateZeroPool (Length);

View File

@ -122,8 +122,8 @@ _IPrint (
// //
Out->OutputString (Out, &BackupBuffer[PreviousIndex]); Out->OutputString (Out, &BackupBuffer[PreviousIndex]);
gBS->FreePool (Buffer); FreePool (Buffer);
gBS->FreePool (BackupBuffer); FreePool (BackupBuffer);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -202,51 +202,6 @@ Returns:
return Print ((CHAR16 *) L"%c", Character); return Print ((CHAR16 *) L"%c", Character);
} }
/*
UINTN
PrintToken (
IN EFI_HII_HANDLE Handle,
IN UINT16 Token,
IN CHAR16 *Language,
...
)
{
VA_LIST args;
UINTN NumberOfHiiHandles;
EFI_HANDLE *HandleBuffer;
EFI_HII_PROTOCOL *Hii;
//
// There should only be one HII image
//
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiHiiProtocolGuid,
NULL,
&NumberOfHiiHandles,
&HandleBuffer
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Retrieve the Hii protocol interface
//
Status = gBS->HandleProtocol (
HandleBuffer[0],
&gEfiHiiProtocolGuid,
&Hii
);
Hii->GetString (Hii, Handle, Token, FALSE, Language,
VA_START (args, fmt);
return _IPrint ((UINTN) -1, (UINTN) -1, gST->ConOut, fmt, args);
}
*/
UINTN UINTN
PrintAt ( PrintAt (
IN UINTN Column, IN UINTN Column,

View File

@ -138,7 +138,7 @@ AdjustNvMap (
} }
} }
gBS->FreePool (VariableDefinition->NvRamMap); FreePool (VariableDefinition->NvRamMap);
VariableDefinition->NvRamMap = NvRamMap; VariableDefinition->NvRamMap = NvRamMap;
VariableDefinition->VariableFakeSize = (UINT16) SizeRequired; VariableDefinition->VariableFakeSize = (UINT16) SizeRequired;
} }
@ -226,7 +226,7 @@ ProcessOptions (
); );
if (*OptionString != NULL) { if (*OptionString != NULL) {
gBS->FreePool (*OptionString); FreePool (*OptionString);
*OptionString = NULL; *OptionString = NULL;
} }
@ -311,7 +311,7 @@ ProcessOptions (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
if (Tag->Operand == EFI_IFR_ORDERED_LIST_OP) { if (Tag->Operand == EFI_IFR_ORDERED_LIST_OP) {
CopyMem (NvRamMap, ValueArray, MenuOption->ThisTag->StorageWidth); CopyMem (NvRamMap, ValueArray, MenuOption->ThisTag->StorageWidth);
gBS->FreePool (ValueArray); FreePool (ValueArray);
} else { } else {
// //
// Since the value can be one byte long or two bytes long, do a CopyMem based on StorageWidth // Since the value can be one byte long or two bytes long, do a CopyMem based on StorageWidth
@ -359,7 +359,7 @@ ProcessOptions (
// Since the value can be one byte long or two bytes long, do a CopyMem based on StorageWidth // Since the value can be one byte long or two bytes long, do a CopyMem based on StorageWidth
// //
CopyMem (NvRamMap, &Number, MenuOption->ThisTag->StorageWidth); CopyMem (NvRamMap, &Number, MenuOption->ThisTag->StorageWidth);
gBS->FreePool (StringPtr); FreePool (StringPtr);
break; break;
default: default:
@ -372,7 +372,7 @@ ProcessOptions (
UpdateStatusBar (NV_UPDATE_REQUIRED, Tag->Flags, TRUE); UpdateStatusBar (NV_UPDATE_REQUIRED, Tag->Flags, TRUE);
} else { } else {
if (Tag->Operand == EFI_IFR_ORDERED_LIST_OP) { if (Tag->Operand == EFI_IFR_ORDERED_LIST_OP) {
gBS->FreePool (ValueArray); FreePool (ValueArray);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@ -434,7 +434,7 @@ ProcessOptions (
// //
// Remove Buffer allocated for StringPtr after it has been used. // Remove Buffer allocated for StringPtr after it has been used.
// //
gBS->FreePool (StringPtr); FreePool (StringPtr);
} else { } else {
// //
// The option value is the same as what is stored in NV store. Print this. // The option value is the same as what is stored in NV store. Print this.
@ -447,7 +447,7 @@ ProcessOptions (
// //
// Remove Buffer allocated for StringPtr after it has been used. // Remove Buffer allocated for StringPtr after it has been used.
// //
gBS->FreePool (StringPtr); FreePool (StringPtr);
Default = 0; Default = 0;
break; break;
} }
@ -475,7 +475,7 @@ ProcessOptions (
// //
// Remove Buffer allocated for StringPtr after it has been used. // Remove Buffer allocated for StringPtr after it has been used.
// //
gBS->FreePool (StringPtr); FreePool (StringPtr);
} }
} }
break; break;
@ -1028,7 +1028,7 @@ ProcessOptions (
UpdateStatusBar (NV_UPDATE_REQUIRED, Tag->Flags, TRUE); UpdateStatusBar (NV_UPDATE_REQUIRED, Tag->Flags, TRUE);
} }
gBS->FreePool (StringPtr); FreePool (StringPtr);
return Status; return Status;
} else { } else {
for (Index = 0; Index < gOptionBlockWidth; Index++) { for (Index = 0; Index < gOptionBlockWidth; Index++) {
@ -1073,13 +1073,13 @@ ProcessOptions (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_READY) { if (Status == EFI_NOT_READY) {
gBS->FreePool (StringPtr); FreePool (StringPtr);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
Status = ReadPassword (MenuOption, TRUE, Tag, PageData, TRUE, FileFormTags, StringPtr); Status = ReadPassword (MenuOption, TRUE, Tag, PageData, TRUE, FileFormTags, StringPtr);
gBS->FreePool (StringPtr); FreePool (StringPtr);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -1090,7 +1090,7 @@ ProcessOptions (
// //
Status = ReadPassword (MenuOption, TRUE, Tag, PageData, FALSE, FileFormTags, StringPtr); Status = ReadPassword (MenuOption, TRUE, Tag, PageData, FALSE, FileFormTags, StringPtr);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->FreePool (StringPtr); FreePool (StringPtr);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -1102,7 +1102,7 @@ ProcessOptions (
} }
if (Status != 0) { if (Status != 0) {
gBS->FreePool (StringPtr); FreePool (StringPtr);
return EFI_SUCCESS; return EFI_SUCCESS;
} else { } else {
break; break;
@ -1123,7 +1123,7 @@ ProcessOptions (
// //
// User couldn't figure out how to type two identical passwords // User couldn't figure out how to type two identical passwords
// //
gBS->FreePool (StringPtr); FreePool (StringPtr);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
@ -1180,8 +1180,8 @@ ProcessOptions (
); );
} }
gBS->FreePool (TmpNvRamMap); FreePool (TmpNvRamMap);
gBS->FreePool (StringPtr); FreePool (StringPtr);
break; break;
} }

View File

@ -292,7 +292,7 @@ Returns:
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->FreePool (CallbackData); FreePool (CallbackData);
return Status;; return Status;;
} }
@ -304,7 +304,7 @@ Returns:
Status = InitializeBinaryStructures (Handle, UseDatabase, Packet, NvMapOverride, HandleCount, &FileFormTagsHead); Status = InitializeBinaryStructures (Handle, UseDatabase, Packet, NvMapOverride, HandleCount, &FileFormTagsHead);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->FreePool (CallbackData); FreePool (CallbackData);
return Status; return Status;
} }
// //
@ -327,7 +327,7 @@ Returns:
if (UseDatabase && (HandleCount > 1)) { if (UseDatabase && (HandleCount > 1)) {
if (Selection == NULL) { if (Selection == NULL) {
gBS->FreePool (CallbackData); FreePool (CallbackData);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
@ -357,12 +357,12 @@ Returns:
*Handle = BackupHandle; *Handle = BackupHandle;
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->FreePool (CallbackData); FreePool (CallbackData);
return Status; return Status;
} }
if (Callback && (AltSelection == NULL)) { if (Callback && (AltSelection == NULL)) {
gBS->FreePool (CallbackData); FreePool (CallbackData);
return Status; return Status;
} }
@ -379,7 +379,7 @@ Returns:
// //
// If this is the FrontPage, return after every selection // If this is the FrontPage, return after every selection
// //
gBS->FreePool (Selection); FreePool (Selection);
UiFreeMenu (); UiFreeMenu ();
// //
@ -390,11 +390,11 @@ Returns:
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
gST->ConOut->ClearScreen (gST->ConOut); gST->ConOut->ClearScreen (gST->ConOut);
gBS->FreePool (CallbackData); FreePool (CallbackData);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
gBS->FreePool (Selection); FreePool (Selection);
UiFreeMenu (); UiFreeMenu ();
// //
@ -405,14 +405,14 @@ Returns:
gST->ConOut->ClearScreen (gST->ConOut); gST->ConOut->ClearScreen (gST->ConOut);
if (!Callback) { if (!Callback) {
gBS->FreePool (CallbackData); FreePool (CallbackData);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
} while (!EFI_ERROR (Status)); } while (!EFI_ERROR (Status));
gBS->FreePool (CallbackData); FreePool (CallbackData);
return Status; return Status;
} }
@ -491,7 +491,7 @@ Returns:
Status = Hii->NewPack (Hii, PackageList, &gHiiHandle); Status = Hii->NewPack (Hii, PackageList, &gHiiHandle);
gBS->FreePool (PackageList); FreePool (PackageList);
// //
// Install protocol interface // Install protocol interface
@ -829,13 +829,14 @@ InitializeTagStructures (
// //
for (Index = 0; Index < NumberOfTags; Index++) { for (Index = 0; Index < NumberOfTags; Index++) {
if (FormTags->Tags[Index].IntList != NULL) { if (FormTags->Tags[Index].IntList != NULL) {
gBS->FreePool (FormTags->Tags[Index].IntList); FreePool (FormTags->Tags[Index].IntList);
} }
} }
gBS->FreePool (FormTags->Tags); FreePool (FormTags->Tags);
gBS->FreePool (FormTags->Next);
FormTags->Next = NULL; ASSERT (FormTags->Next == NULL);
FormTags->Tags = NULL; FormTags->Tags = NULL;
FormTags = SavedFormTags; FormTags = SavedFormTags;
@ -1571,8 +1572,8 @@ InitPage (
HomeEscapeString HomeEscapeString
); );
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
gBS->FreePool (HomeEscapeString); FreePool (HomeEscapeString);
gBS->FreePool (HomePageString); FreePool (HomePageString);
return ; return ;
} }
@ -1618,7 +1619,7 @@ Returns:
// //
// Free the old pool // Free the old pool
// //
gBS->FreePool (Buffer); FreePool (Buffer);
// //
// Allocate new pool with correct value // Allocate new pool with correct value
@ -1955,8 +1956,8 @@ InitializeBinaryStructures (
// //
// Free the buffer that was allocated that was too small // Free the buffer that was allocated that was too small
// //
gBS->FreePool (VariableDefinition->NvRamMap); FreePool (VariableDefinition->NvRamMap);
gBS->FreePool (VariableDefinition->FakeNvRamMap); FreePool (VariableDefinition->FakeNvRamMap);
VariableDefinition->NvRamMap = AllocateZeroPool (SizeOfNvStore); VariableDefinition->NvRamMap = AllocateZeroPool (SizeOfNvStore);
VariableDefinition->FakeNvRamMap = AllocateZeroPool (SizeOfNvStore + VariableDefinition->VariableFakeSize); VariableDefinition->FakeNvRamMap = AllocateZeroPool (SizeOfNvStore + VariableDefinition->VariableFakeSize);
@ -2010,8 +2011,8 @@ InitializeBinaryStructures (
// //
// Free the buffer that was allocated. // Free the buffer that was allocated.
// //
gBS->FreePool (VariableDefinition->NvRamMap); FreePool (VariableDefinition->NvRamMap);
gBS->FreePool (VariableDefinition->FakeNvRamMap); FreePool (VariableDefinition->FakeNvRamMap);
// //
// Allocate, copy the NvRamMap. // Allocate, copy the NvRamMap.
@ -2024,7 +2025,7 @@ InitializeBinaryStructures (
VariableDefinition->FakeNvRamMap = AllocateZeroPool (NvMapSize + VariableDefinition->VariableFakeSize); VariableDefinition->FakeNvRamMap = AllocateZeroPool (NvMapSize + VariableDefinition->VariableFakeSize);
CopyMem (VariableDefinition->NvRamMap, NvMap, NvMapSize); CopyMem (VariableDefinition->NvRamMap, NvMap, NvMapSize);
gBS->FreePool (NvMapListHead); FreePool (NvMapListHead);
} }
} }
@ -2098,7 +2099,7 @@ Returns:
if (Status == EFI_BUFFER_TOO_SMALL) { if (Status == EFI_BUFFER_TOO_SMALL) {
gBS->FreePool (Buffer); FreePool (Buffer);
// //
// Allocate memory for our Form binary // Allocate memory for our Form binary
@ -2121,7 +2122,7 @@ Returns:
Status = Hii->NewPack (Hii, PackageList, &HiiHandle); Status = Hii->NewPack (Hii, PackageList, &HiiHandle);
gBS->FreePool (PackageList); FreePool (PackageList);
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {

View File

@ -119,7 +119,7 @@ Returns:
(*PreviousSelection)->Handle = UiMenuList->Selection.Handle; (*PreviousSelection)->Handle = UiMenuList->Selection.Handle;
gEntryNumber = UiMenuList->FormerEntryNumber; gEntryNumber = UiMenuList->FormerEntryNumber;
RemoveEntryList (&UiMenuList->MenuLink); RemoveEntryList (&UiMenuList->MenuLink);
gBS->FreePool (UiMenuList); FreePool (UiMenuList);
} }
} }
@ -143,7 +143,7 @@ Returns:
while (!IsListEmpty (&gMenuList)) { while (!IsListEmpty (&gMenuList)) {
UiMenuList = CR (gMenuList.ForwardLink, UI_MENU_LIST, MenuLink, UI_MENU_LIST_SIGNATURE); UiMenuList = CR (gMenuList.ForwardLink, UI_MENU_LIST, MenuLink, UI_MENU_LIST_SIGNATURE);
RemoveEntryList (&UiMenuList->MenuLink); RemoveEntryList (&UiMenuList->MenuLink);
gBS->FreePool (UiMenuList); FreePool (UiMenuList);
} }
} }
@ -197,8 +197,8 @@ Returns:
// //
// We allocated space for this description when we did a GetToken, free it here // We allocated space for this description when we did a GetToken, free it here
// //
gBS->FreePool (MenuOption->Description); FreePool (MenuOption->Description);
gBS->FreePool (MenuOption); FreePool (MenuOption);
} }
} }
@ -256,7 +256,7 @@ Returns:
} }
if (OptionString != NULL) { if (OptionString != NULL) {
gBS->FreePool (OptionString); FreePool (OptionString);
} }
} }
@ -572,8 +572,8 @@ Returns:
case CHAR_NULL: case CHAR_NULL:
switch (Key.ScanCode) { switch (Key.ScanCode) {
case SCAN_ESC: case SCAN_ESC:
gBS->FreePool (TempString); FreePool (TempString);
gBS->FreePool (BufferedString); FreePool (BufferedString);
gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute); gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute);
gST->ConOut->EnableCursor (gST->ConOut, TRUE); gST->ConOut->EnableCursor (gST->ConOut, TRUE);
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
@ -586,8 +586,8 @@ Returns:
case CHAR_CARRIAGE_RETURN: case CHAR_CARRIAGE_RETURN:
SelectionComplete = TRUE; SelectionComplete = TRUE;
gBS->FreePool (TempString); FreePool (TempString);
gBS->FreePool (BufferedString); FreePool (BufferedString);
gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute); gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute);
gST->ConOut->EnableCursor (gST->ConOut, TRUE); gST->ConOut->EnableCursor (gST->ConOut, TRUE);
return EFI_SUCCESS; return EFI_SUCCESS;
@ -829,8 +829,8 @@ UpdateStatusBar (
break; break;
} }
gBS->FreePool (InputErrorMessage); FreePool (InputErrorMessage);
gBS->FreePool (NvUpdateMessage); FreePool (NvUpdateMessage);
return ; return ;
} }
@ -867,11 +867,11 @@ Returns:
FileForm = FileFormTagsHead; FileForm = FileFormTagsHead;
if (FormattedString != NULL) { if (FormattedString != NULL) {
gBS->FreePool (FormattedString); FreePool (FormattedString);
} }
if (OptionString != NULL) { if (OptionString != NULL) {
gBS->FreePool (OptionString); FreePool (OptionString);
} }
for (; FileForm != NULL;) { for (; FileForm != NULL;) {
@ -908,17 +908,17 @@ Returns:
} }
if (FormTags->Tags[Index].IntList != NULL) { if (FormTags->Tags[Index].IntList != NULL) {
gBS->FreePool (FormTags->Tags[Index].IntList); FreePool (FormTags->Tags[Index].IntList);
} }
} }
if (PreviousFormTags != NULL) { if (PreviousFormTags != NULL) {
gBS->FreePool (FormTags->Tags); FreePool (FormTags->Tags);
FormTags = PreviousFormTags; FormTags = PreviousFormTags;
gBS->FreePool (FormTags->Next); FreePool (FormTags->Next);
FormTags->Next = NULL; FormTags->Next = NULL;
} else { } else {
gBS->FreePool (FormTags->Tags); FreePool (FormTags->Tags);
FormTags = NULL; FormTags = NULL;
} }
} }
@ -942,7 +942,7 @@ Returns:
// //
// Free the current entry // Free the current entry
// //
gBS->FreePool (Inconsistent); FreePool (Inconsistent);
// //
// Restore the Previous pointer // Restore the Previous pointer
@ -963,26 +963,32 @@ Returns:
PreviousVariableDefinition = VariableDefinition; PreviousVariableDefinition = VariableDefinition;
} }
gBS->FreePool (VariableDefinition->VariableName); FreePool (VariableDefinition->VariableName);
gBS->FreePool (VariableDefinition->NvRamMap);
gBS->FreePool (VariableDefinition->FakeNvRamMap); if (VariableDefinition->NvRamMap != NULL) {
FreePool (VariableDefinition->NvRamMap);
}
if (VariableDefinition->FakeNvRamMap != NULL) {
FreePool (VariableDefinition->FakeNvRamMap);
}
if (PreviousVariableDefinition != NULL) { if (PreviousVariableDefinition != NULL) {
VariableDefinition = PreviousVariableDefinition; VariableDefinition = PreviousVariableDefinition;
gBS->FreePool (VariableDefinition->Next); FreePool (VariableDefinition->Next);
VariableDefinition->Next = NULL; VariableDefinition->Next = NULL;
} else { } else {
gBS->FreePool (VariableDefinition); FreePool (VariableDefinition);
VariableDefinition = NULL; VariableDefinition = NULL;
} }
} }
if (PreviousFileForm != NULL) { if (PreviousFileForm != NULL) {
FileForm = PreviousFileForm; FileForm = PreviousFileForm;
gBS->FreePool (FileForm->NextFile); FreePool (FileForm->NextFile);
FileForm->NextFile = NULL; FileForm->NextFile = NULL;
} else { } else {
gBS->FreePool (FileForm); FreePool (FileForm);
FileForm = NULL; FileForm = NULL;
} }
} }
@ -1000,40 +1006,40 @@ Returns:
PreviousIfrBinary = IfrBinary; PreviousIfrBinary = IfrBinary;
} }
gBS->FreePool (IfrBinary->IfrPackage); FreePool (IfrBinary->IfrPackage);
if (PreviousIfrBinary != NULL) { if (PreviousIfrBinary != NULL) {
IfrBinary = PreviousIfrBinary; IfrBinary = PreviousIfrBinary;
gBS->FreePool (IfrBinary->Next); FreePool (IfrBinary->Next);
IfrBinary->Next = NULL; IfrBinary->Next = NULL;
} else { } else {
gBS->FreePool (IfrBinary); FreePool (IfrBinary);
IfrBinary = NULL; IfrBinary = NULL;
} }
} }
gBS->FreePool (gPreviousValue); FreePool (gPreviousValue);
gPreviousValue = NULL; gPreviousValue = NULL;
// //
// Free Browser Strings // Free Browser Strings
// //
gBS->FreePool (gPressEnter); FreePool (gPressEnter);
gBS->FreePool (gConfirmError); FreePool (gConfirmError);
gBS->FreePool (gConfirmPassword); FreePool (gConfirmPassword);
gBS->FreePool (gPromptForNewPassword); FreePool (gPromptForNewPassword);
gBS->FreePool (gPromptForPassword); FreePool (gPromptForPassword);
gBS->FreePool (gToggleCheckBox); FreePool (gToggleCheckBox);
gBS->FreePool (gNumericInput); FreePool (gNumericInput);
gBS->FreePool (gMakeSelection); FreePool (gMakeSelection);
gBS->FreePool (gMoveHighlight); FreePool (gMoveHighlight);
gBS->FreePool (gEscapeString); FreePool (gEscapeString);
gBS->FreePool (gEnterCommitString); FreePool (gEnterCommitString);
gBS->FreePool (gEnterString); FreePool (gEnterString);
gBS->FreePool (gFunctionOneString); FreePool (gFunctionOneString);
gBS->FreePool (gFunctionTwoString); FreePool (gFunctionTwoString);
gBS->FreePool (gFunctionNineString); FreePool (gFunctionNineString);
gBS->FreePool (gFunctionTenString); FreePool (gFunctionTenString);
return ; return ;
} }
@ -1103,7 +1109,7 @@ Returns:
// Since the value can be one byte long or two bytes long, do a CopyMem based on StorageWidth // Since the value can be one byte long or two bytes long, do a CopyMem based on StorageWidth
// //
CopyMem (NvRamMap, &Tag->OldValue, Tag->StorageWidth); CopyMem (NvRamMap, &Tag->OldValue, Tag->StorageWidth);
gBS->FreePool (StringPtr); FreePool (StringPtr);
break; break;
default: default:
@ -1151,7 +1157,7 @@ Returns:
if ((Tag->Operand == EFI_IFR_TEXT_OP) && (Tag->TextTwo != 0)) { if ((Tag->Operand == EFI_IFR_TEXT_OP) && (Tag->TextTwo != 0)) {
String = GetToken (Tag->TextTwo, Handle); String = GetToken (Tag->TextTwo, Handle);
Size = StrLen (String); Size = StrLen (String);
gBS->FreePool (String); FreePool (String);
} }
if ((Tag->Operand == EFI_IFR_SUBTITLE_OP) || if ((Tag->Operand == EFI_IFR_SUBTITLE_OP) ||
@ -1323,7 +1329,7 @@ UpdateOptionSkipLines (
} }
} }
gBS->FreePool (OutputString); FreePool (OutputString);
if (SkipValue != 0) { if (SkipValue != 0) {
SkipValue--; SkipValue--;
} }
@ -1548,7 +1554,7 @@ Returns:
while (gMenuRefreshHead != NULL) { while (gMenuRefreshHead != NULL) {
OldMenuRefreshEntry = gMenuRefreshHead->Next; OldMenuRefreshEntry = gMenuRefreshHead->Next;
gBS->FreePool (gMenuRefreshHead); FreePool (gMenuRefreshHead);
gMenuRefreshHead = OldMenuRefreshEntry; gMenuRefreshHead = OldMenuRefreshEntry;
} }
@ -1586,7 +1592,7 @@ Returns:
} }
} }
gBS->FreePool (OutputString); FreePool (OutputString);
if (Temp != 0) { if (Temp != 0) {
Temp--; Temp--;
} }
@ -1681,7 +1687,7 @@ Returns:
} }
} }
gBS->FreePool (OutputString); FreePool (OutputString);
if (Temp2 != 0) { if (Temp2 != 0) {
Temp2--; Temp2--;
} }
@ -1723,14 +1729,14 @@ Returns:
} }
} }
gBS->FreePool (OutputString); FreePool (OutputString);
if (Temp2 != 0) { if (Temp2 != 0) {
Temp2--; Temp2--;
} }
} }
Row = OriginalRow; Row = OriginalRow;
gBS->FreePool (StringPtr); FreePool (StringPtr);
} }
} else { } else {
// //
@ -1848,7 +1854,7 @@ Returns:
MenuOption->Row++; MenuOption->Row++;
} }
gBS->FreePool (OutputString); FreePool (OutputString);
} }
MenuOption->Row = OriginalRow; MenuOption->Row = OriginalRow;
@ -1876,7 +1882,7 @@ Returns:
MenuOption->Row++; MenuOption->Row++;
} }
gBS->FreePool (OutputString); FreePool (OutputString);
} }
MenuOption->Row = OriginalRow; MenuOption->Row = OriginalRow;
@ -1969,7 +1975,7 @@ Returns:
MenuOption->Row++; MenuOption->Row++;
} }
gBS->FreePool (OutputString); FreePool (OutputString);
} }
MenuOption->Row = OriginalRow; MenuOption->Row = OriginalRow;
@ -1990,7 +1996,7 @@ Returns:
MenuOption->Row++; MenuOption->Row++;
} }
gBS->FreePool (OutputString); FreePool (OutputString);
} }
MenuOption->Row = OriginalRow; MenuOption->Row = OriginalRow;
@ -2305,7 +2311,7 @@ Returns:
while (gMenuRefreshHead != NULL) { while (gMenuRefreshHead != NULL) {
OldMenuRefreshEntry = gMenuRefreshHead->Next; OldMenuRefreshEntry = gMenuRefreshHead->Next;
gBS->FreePool (gMenuRefreshHead); FreePool (gMenuRefreshHead);
gMenuRefreshHead = OldMenuRefreshEntry; gMenuRefreshHead = OldMenuRefreshEntry;
} }
@ -2981,8 +2987,8 @@ Returns:
// //
// Free the buffer that was allocated. // Free the buffer that was allocated.
// //
gBS->FreePool (FileFormTags->VariableDefinitions->NvRamMap); FreePool (FileFormTags->VariableDefinitions->NvRamMap);
gBS->FreePool (FileFormTags->VariableDefinitions->FakeNvRamMap); FreePool (FileFormTags->VariableDefinitions->FakeNvRamMap);
// //
// Allocate, copy the NvRamMap. // Allocate, copy the NvRamMap.
@ -2998,7 +3004,7 @@ Returns:
ASSERT (FileFormTags->VariableDefinitions->FakeNvRamMap != NULL); ASSERT (FileFormTags->VariableDefinitions->FakeNvRamMap != NULL);
CopyMem (FileFormTags->VariableDefinitions->NvRamMap, NvMap, NvMapSize); CopyMem (FileFormTags->VariableDefinitions->NvRamMap, NvMap, NvMapSize);
gBS->FreePool (NvMapListHead); FreePool (NvMapListHead);
} }
UpdateStatusBar (NV_UPDATE_REQUIRED, MenuOption->ThisTag->Flags, TRUE); UpdateStatusBar (NV_UPDATE_REQUIRED, MenuOption->ThisTag->Flags, TRUE);
@ -3017,7 +3023,7 @@ Returns:
while (gMenuRefreshHead != NULL) { while (gMenuRefreshHead != NULL) {
OldMenuRefreshEntry = gMenuRefreshHead->Next; OldMenuRefreshEntry = gMenuRefreshHead->Next;
gBS->FreePool (gMenuRefreshHead); FreePool (gMenuRefreshHead);
gMenuRefreshHead = OldMenuRefreshEntry; gMenuRefreshHead = OldMenuRefreshEntry;
} }

View File

@ -424,13 +424,9 @@ Returns:
Variable = NextVariable; Variable = NextVariable;
} }
Status = gBS->AllocatePool ( ValidBuffer = AllocatePool (ValidBufferSize);
EfiBootServicesData, if (ValidBuffer == NULL) {
ValidBufferSize, return EFI_OUT_OF_RESOURCES;
(VOID **) &ValidBuffer
);
if (EFI_ERROR (Status)) {
return Status;
} }
SetMem (ValidBuffer, ValidBufferSize, 0xff); SetMem (ValidBuffer, ValidBufferSize, 0xff);
@ -481,7 +477,7 @@ Returns:
} }
} }
gBS->FreePool (ValidBuffer); FreePool (ValidBuffer);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
*LastVariableOffset = 0; *LastVariableOffset = 0;
@ -1308,14 +1304,9 @@ Returns:
UINTN Index; UINTN Index;
UINT8 Data; UINT8 Data;
Status = gBS->AllocatePool ( mVariableModuleGlobal = AllocateRuntimePool (sizeof (ESAL_VARIABLE_GLOBAL));
EfiRuntimeServicesData, if (mVariableModuleGlobal == NULL) {
sizeof (ESAL_VARIABLE_GLOBAL), return EFI_OUT_OF_RESOURCES;
(VOID **) &mVariableModuleGlobal
);
if (EFI_ERROR (Status)) {
return Status;
} }
EfiInitializeLock(&mVariableModuleGlobal->VariableGlobal[Physical].VariableServicesLock, EFI_TPL_NOTIFY); EfiInitializeLock(&mVariableModuleGlobal->VariableGlobal[Physical].VariableServicesLock, EFI_TPL_NOTIFY);
@ -1323,15 +1314,10 @@ Returns:
// //
// Allocate memory for volatile variable store // Allocate memory for volatile variable store
// //
Status = gBS->AllocatePool ( VolatileVariableStore = AllocateRuntimePool (VARIABLE_STORE_SIZE + SCRATCH_SIZE);
EfiRuntimeServicesData, if (VolatileVariableStore == NULL) {
VARIABLE_STORE_SIZE + SCRATCH_SIZE, FreePool (mVariableModuleGlobal);
(VOID **) &VolatileVariableStore return EFI_OUT_OF_RESOURCES;
);
if (EFI_ERROR (Status)) {
gBS->FreePool (mVariableModuleGlobal);
return Status;
} }
SetMem (VolatileVariableStore, VARIABLE_STORE_SIZE + SCRATCH_SIZE, 0xff); SetMem (VolatileVariableStore, VARIABLE_STORE_SIZE + SCRATCH_SIZE, 0xff);
@ -1367,8 +1353,8 @@ Returns:
Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor); Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->FreePool (mVariableModuleGlobal); FreePool (mVariableModuleGlobal);
gBS->FreePool (VolatileVariableStore); FreePool (VolatileVariableStore);
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -1378,8 +1364,8 @@ Returns:
GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->FreePool (mVariableModuleGlobal); FreePool (mVariableModuleGlobal);
gBS->FreePool (VolatileVariableStore); FreePool (VolatileVariableStore);
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
// //
@ -1448,8 +1434,8 @@ Returns:
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->FreePool (mVariableModuleGlobal); FreePool (mVariableModuleGlobal);
gBS->FreePool (VolatileVariableStore); FreePool (VolatileVariableStore);
return Status; return Status;
} }
@ -1473,8 +1459,8 @@ Returns:
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->FreePool (mVariableModuleGlobal); FreePool (mVariableModuleGlobal);
gBS->FreePool (VolatileVariableStore); FreePool (VolatileVariableStore);
} }
return Status; return Status;

View File

@ -52,6 +52,9 @@
<LibraryClass Usage="ALWAYS_CONSUMED"> <LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseLib</Keyword> <Keyword>BaseLib</Keyword>
</LibraryClass> </LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>MemoryAllocationLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions> </LibraryClassDefinitions>
<SourceFiles> <SourceFiles>
<Filename>Variable.h</Filename> <Filename>Variable.h</Filename>

View File

@ -55,6 +55,9 @@
<LibraryClass Usage="ALWAYS_CONSUMED"> <LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseLib</Keyword> <Keyword>BaseLib</Keyword>
</LibraryClass> </LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>MemoryAllocationLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions> </LibraryClassDefinitions>
<SourceFiles> <SourceFiles>
<Filename>Variable.h</Filename> <Filename>Variable.h</Filename>

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006 - 2007, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -82,7 +82,7 @@ GetFvbHandleByAddress (
} }
} }
gBS->FreePool (HandleBuffer); FreePool (HandleBuffer);
return Status; return Status;
} }
@ -216,8 +216,8 @@ Returns:
// Prepare for the variable data // Prepare for the variable data
// //
FtwBufferSize = ((VARIABLE_STORE_HEADER *) ((UINTN) VariableBase))->Size; FtwBufferSize = ((VARIABLE_STORE_HEADER *) ((UINTN) VariableBase))->Size;
Status = gBS->AllocatePool (EfiRuntimeServicesData, FtwBufferSize, (VOID **) &FtwBuffer); FtwBuffer = AllocateRuntimePool (FtwBufferSize);
if (EFI_ERROR (Status)) { if (FtwBuffer == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -236,6 +236,6 @@ Returns:
FtwBuffer FtwBuffer
); );
gBS->FreePool (FtwBuffer); FreePool (FtwBuffer);
return Status; return Status;
} }