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
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
@ -576,8 +576,8 @@ Returns:
//
// Allocate the buffer to return
//
Status = gBS->AllocatePool (EfiBootServicesData, BufferSize, &Buffer);
if (EFI_ERROR (Status)) {
Buffer = AllocatePool (BufferSize);
if (Buffer == NULL) {
return NULL;
}
//
@ -591,7 +591,7 @@ Returns:
Buffer
);
if (EFI_ERROR (Status)) {
gBS->FreePool (Buffer);
FreePool (Buffer);
Buffer = NULL;
}
}
@ -658,7 +658,7 @@ Returns:
while (DevicePathInst) {
if (CompareMem (Single, DevicePathInst, Size) == 0) {
if (!Delete) {
gBS->FreePool (DevicePathInst);
FreePool (DevicePathInst);
return EFI_SUCCESS;
}
} else {
@ -667,12 +667,14 @@ Returns:
TempDevicePath1,
DevicePathInst
);
gBS->FreePool (TempDevicePath1);
if (TempDevicePath1 != NULL) {
FreePool (TempDevicePath1);
}
TempDevicePath1 = TempDevicePath2;
}
}
gBS->FreePool (DevicePathInst);
FreePool (DevicePathInst);
DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);
}
@ -730,7 +732,9 @@ Returns:
//
// The device path is already in the variable
//
gBS->FreePool (VariableDevicePath);
if (VariableDevicePath != NULL) {
FreePool (VariableDevicePath);
}
return Status;
}
@ -760,7 +764,9 @@ Returns:
);
}
gBS->FreePool (VariableDevicePath);
if (VariableDevicePath != NULL) {
FreePool (VariableDevicePath);
}
if (EFI_ERROR (Status)) {
return Status;
@ -774,7 +780,7 @@ Returns:
NewVariableDevicePath
);
gBS->FreePool (NewVariableDevicePath);
FreePool (NewVariableDevicePath);
return Status;
}

View File

@ -46,6 +46,9 @@
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DevicePathLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>MemoryAllocationLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<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
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
@ -76,7 +76,7 @@ Returns:
//
// Free The Old Stack
//
gBS->FreePool (mBooleanEvaluationStack);
FreePool (mBooleanEvaluationStack);
}
mBooleanEvaluationStack = NewStack;
@ -201,7 +201,7 @@ GrowBooleanExpression (
//
// Free The Old buffer
//
gBS->FreePool (*BooleanExpression);
FreePool (*BooleanExpression);
} else {
//
// Copy data into new buffer
@ -498,7 +498,7 @@ Returns:
MapValue = (UINT8) *MapBuffer;
}
gBS->FreePool (MapBuffer);
FreePool (MapBuffer);
}
if (MapBuffer2 != NULL) {
@ -508,7 +508,7 @@ Returns:
MapValue2 = (UINT8) *MapBuffer2;
}
gBS->FreePool (MapBuffer2);
FreePool (MapBuffer2);
}
}
@ -741,7 +741,7 @@ Returns:
MapValue = (UINT8) *MapBuffer;
}
gBS->FreePool (MapBuffer);
FreePool (MapBuffer);
}
if (MapBuffer2 != NULL) {
@ -751,7 +751,7 @@ Returns:
MapValue2 = (UINT8) *MapBuffer2;
}
gBS->FreePool (MapBuffer2);
FreePool (MapBuffer2);
}
}
@ -913,7 +913,7 @@ Returns:
MapValue = (UINT8) *MapBuffer;
}
gBS->FreePool (MapBuffer);
FreePool (MapBuffer);
}
if (MapBuffer2 != NULL) {
@ -923,7 +923,7 @@ Returns:
MapValue2 = (UINT8) *MapBuffer2;
}
gBS->FreePool (MapBuffer2);
FreePool (MapBuffer2);
}
}
@ -1049,7 +1049,7 @@ Returns:
MapValue = (UINT8) *MapBuffer;
}
gBS->FreePool (MapBuffer);
FreePool (MapBuffer);
}
if (MapBuffer2 != NULL) {
@ -1059,7 +1059,7 @@ Returns:
MapValue2 = (UINT8) *MapBuffer2;
}
gBS->FreePool (MapBuffer2);
FreePool (MapBuffer2);
}
}
@ -1205,7 +1205,7 @@ Returns:
MapValue = (UINT8) *MapBuffer;
}
gBS->FreePool (MapBuffer);
FreePool (MapBuffer);
}
if (MapBuffer2 != NULL) {
@ -1215,7 +1215,7 @@ Returns:
MapValue2 = (UINT8) *MapBuffer2;
}
gBS->FreePool (MapBuffer2);
FreePool (MapBuffer2);
}
}

View File

@ -86,7 +86,7 @@ ReadString(
//
CreatePopUp (ScreenSize, 4, &NullCharacter, PromptForDataString, Space, &NullCharacter);
gBS->FreePool (PromptForDataString);
FreePool (PromptForDataString);
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_BLACK, EFI_LIGHTGRAY));
@ -107,8 +107,8 @@ ReadString(
break;
case SCAN_ESC:
gBS->FreePool (TempString);
gBS->FreePool (BufferedString);
FreePool (TempString);
FreePool (BufferedString);
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
gST->ConOut->EnableCursor (gST->ConOut, CursorVisible);
return EFI_DEVICE_ERROR;
@ -122,8 +122,8 @@ ReadString(
case CHAR_CARRIAGE_RETURN:
if (GetStringWidth (StringPtr) >= MenuOption->ThisTag->Minimum) {
SelectionComplete = TRUE;
gBS->FreePool (TempString);
gBS->FreePool (BufferedString);
FreePool (TempString);
FreePool (BufferedString);
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
gST->ConOut->EnableCursor (gST->ConOut, CursorVisible);
return EFI_SUCCESS;
@ -137,8 +137,8 @@ ReadString(
do {
Status = WaitForKeyStroke (&Key);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
gBS->FreePool (TempString);
gBS->FreePool (BufferedString);
FreePool (TempString);
FreePool (BufferedString);
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
gST->ConOut->EnableCursor (gST->ConOut, CursorVisible);
return EFI_DEVICE_ERROR;
@ -309,7 +309,7 @@ Error:
WidthOfString = GetStringWidth (Packet->String);
ScreenSize = EFI_MAX(WidthOfString, GetStringWidth (gPressEnter)) / 2;
CreatePopUp (ScreenSize, 4, &NullCharacter, Packet->String, gPressEnter, &NullCharacter);
gBS->FreePool (Packet);
FreePool (Packet);
do {
Status = WaitForKeyStroke (&Key);
@ -422,7 +422,7 @@ Error:
WidthOfString = GetStringWidth (Packet->String);
ScreenSize = EFI_MAX (WidthOfString, GetStringWidth (gPressEnter)) / 2;
CreatePopUp (ScreenSize, 4, &NullCharacter, Packet->String, gPressEnter, &NullCharacter);
gBS->FreePool (Packet);
FreePool (Packet);
}
StringPtr[0] = CHAR_NULL;
@ -571,8 +571,8 @@ Error:
} while (1);
Done:
gBS->FreePool (TempString);
gBS->FreePool (TempString2);
FreePool (TempString);
FreePool (TempString2);
return Status;
}
@ -600,7 +600,7 @@ EncodePassword (
CopyMem (Password, Buffer, MaxSize);
gBS->FreePool (Buffer);
FreePool (Buffer);
return ;
}
@ -880,7 +880,7 @@ EnterCarriageReturn:
case CHAR_CARRIAGE_RETURN:
SelectionComplete = TRUE;
gBS->FreePool (StringPtr);
FreePool (StringPtr);
break;
default:
@ -1083,7 +1083,7 @@ GetSelectionInputPopUp (
PopUpWidth = StrLen (StringPtr);
}
gBS->FreePool (StringPtr);
FreePool (StringPtr);
}
}
//
@ -1224,7 +1224,7 @@ GetSelectionInputPopUp (
TempStringPtr = AllocateZeroPool (sizeof (CHAR16) * (PopUpWidth - 1));
ASSERT (TempStringPtr != NULL);
CopyMem (TempStringPtr, StringPtr, (sizeof (CHAR16) * (PopUpWidth - 5)));
gBS->FreePool (StringPtr);
FreePool (StringPtr);
StringPtr = TempStringPtr;
StrCat (StringPtr, (CHAR16 *) L"...");
}
@ -1256,7 +1256,7 @@ GetSelectionInputPopUp (
PrintStringAt (Start + 2, Index2, StringPtr);
}
gBS->FreePool (StringPtr);
FreePool (StringPtr);
Index2 = Index2 + 1;
}
}
@ -1520,7 +1520,7 @@ TheKey:
case SCAN_ESC:
gST->ConOut->SetAttribute (gST->ConOut, SavedAttribute);
if (ValueArrayBackup != NULL) {
gBS->FreePool (ValueArrayBackup);
FreePool (ValueArrayBackup);
}
return EFI_DEVICE_ERROR;
@ -1537,7 +1537,7 @@ TheKey:
//
if (Tag->Operand == EFI_IFR_ORDERED_LIST_OP) {
CopyMem (ValueArray, ValueArrayBackup, ValueCount);
gBS->FreePool (ValueArrayBackup);
FreePool (ValueArrayBackup);
} else {
*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
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
@ -60,7 +60,7 @@ ClearLines (
gST->ConOut->SetCursorPosition (gST->ConOut, LeftColumn, TopRow);
gBS->FreePool (Buffer);
FreePool (Buffer);
return ;
}
@ -237,7 +237,7 @@ DisplayPageFrame (
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.
//
gBS->FreePool (StringPtr);
FreePool (StringPtr);
for (Index = 0; FormTags.Tags[Index].Operand != EFI_IFR_END_FORM_OP; Index++) {
GrayOut = FALSE;
@ -595,7 +595,7 @@ GetOut:
FormTags.Tags[Index].NumberOfLines++;
}
gBS->FreePool (OutputString);
FreePool (OutputString);
}
ArrayEntry = 0;
@ -1212,7 +1212,7 @@ Returns:
);
if (EFI_ERROR (Status)) {
gBS->FreePool (LocalTags->Tags);
FreePool (LocalTags->Tags);
return ;
}
@ -1317,7 +1317,7 @@ Returns:
}
if (Packet != NULL) {
gBS->FreePool (Packet);
FreePool (Packet);
}
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
// We will re-allocate a buffer....
//
gBS->FreePool (LocalTags->Tags);
FreePool (LocalTags->Tags);
Length = 0xF000;
Buffer = AllocateZeroPool (Length);

View File

@ -122,8 +122,8 @@ _IPrint (
//
Out->OutputString (Out, &BackupBuffer[PreviousIndex]);
gBS->FreePool (Buffer);
gBS->FreePool (BackupBuffer);
FreePool (Buffer);
FreePool (BackupBuffer);
return EFI_SUCCESS;
}
@ -202,51 +202,6 @@ Returns:
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
PrintAt (
IN UINTN Column,

View File

@ -138,7 +138,7 @@ AdjustNvMap (
}
}
gBS->FreePool (VariableDefinition->NvRamMap);
FreePool (VariableDefinition->NvRamMap);
VariableDefinition->NvRamMap = NvRamMap;
VariableDefinition->VariableFakeSize = (UINT16) SizeRequired;
}
@ -226,7 +226,7 @@ ProcessOptions (
);
if (*OptionString != NULL) {
gBS->FreePool (*OptionString);
FreePool (*OptionString);
*OptionString = NULL;
}
@ -311,7 +311,7 @@ ProcessOptions (
if (!EFI_ERROR (Status)) {
if (Tag->Operand == EFI_IFR_ORDERED_LIST_OP) {
CopyMem (NvRamMap, ValueArray, MenuOption->ThisTag->StorageWidth);
gBS->FreePool (ValueArray);
FreePool (ValueArray);
} else {
//
// 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
//
CopyMem (NvRamMap, &Number, MenuOption->ThisTag->StorageWidth);
gBS->FreePool (StringPtr);
FreePool (StringPtr);
break;
default:
@ -372,7 +372,7 @@ ProcessOptions (
UpdateStatusBar (NV_UPDATE_REQUIRED, Tag->Flags, TRUE);
} else {
if (Tag->Operand == EFI_IFR_ORDERED_LIST_OP) {
gBS->FreePool (ValueArray);
FreePool (ValueArray);
}
return EFI_SUCCESS;
@ -434,7 +434,7 @@ ProcessOptions (
//
// Remove Buffer allocated for StringPtr after it has been used.
//
gBS->FreePool (StringPtr);
FreePool (StringPtr);
} else {
//
// 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.
//
gBS->FreePool (StringPtr);
FreePool (StringPtr);
Default = 0;
break;
}
@ -475,7 +475,7 @@ ProcessOptions (
//
// Remove Buffer allocated for StringPtr after it has been used.
//
gBS->FreePool (StringPtr);
FreePool (StringPtr);
}
}
break;
@ -1028,7 +1028,7 @@ ProcessOptions (
UpdateStatusBar (NV_UPDATE_REQUIRED, Tag->Flags, TRUE);
}
gBS->FreePool (StringPtr);
FreePool (StringPtr);
return Status;
} else {
for (Index = 0; Index < gOptionBlockWidth; Index++) {
@ -1073,13 +1073,13 @@ ProcessOptions (
if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_READY) {
gBS->FreePool (StringPtr);
FreePool (StringPtr);
return EFI_SUCCESS;
}
}
Status = ReadPassword (MenuOption, TRUE, Tag, PageData, TRUE, FileFormTags, StringPtr);
gBS->FreePool (StringPtr);
FreePool (StringPtr);
return EFI_SUCCESS;
}
@ -1090,7 +1090,7 @@ ProcessOptions (
//
Status = ReadPassword (MenuOption, TRUE, Tag, PageData, FALSE, FileFormTags, StringPtr);
if (EFI_ERROR (Status)) {
gBS->FreePool (StringPtr);
FreePool (StringPtr);
return EFI_SUCCESS;
}
@ -1102,7 +1102,7 @@ ProcessOptions (
}
if (Status != 0) {
gBS->FreePool (StringPtr);
FreePool (StringPtr);
return EFI_SUCCESS;
} else {
break;
@ -1123,7 +1123,7 @@ ProcessOptions (
//
// User couldn't figure out how to type two identical passwords
//
gBS->FreePool (StringPtr);
FreePool (StringPtr);
return EFI_SUCCESS;
}
//
@ -1180,8 +1180,8 @@ ProcessOptions (
);
}
gBS->FreePool (TmpNvRamMap);
gBS->FreePool (StringPtr);
FreePool (TmpNvRamMap);
FreePool (StringPtr);
break;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -55,6 +55,9 @@
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>MemoryAllocationLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<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
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
@ -82,7 +82,7 @@ GetFvbHandleByAddress (
}
}
gBS->FreePool (HandleBuffer);
FreePool (HandleBuffer);
return Status;
}
@ -216,8 +216,8 @@ Returns:
// Prepare for the variable data
//
FtwBufferSize = ((VARIABLE_STORE_HEADER *) ((UINTN) VariableBase))->Size;
Status = gBS->AllocatePool (EfiRuntimeServicesData, FtwBufferSize, (VOID **) &FtwBuffer);
if (EFI_ERROR (Status)) {
FtwBuffer = AllocateRuntimePool (FtwBufferSize);
if (FtwBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@ -236,6 +236,6 @@ Returns:
FtwBuffer
);
gBS->FreePool (FtwBuffer);
FreePool (FtwBuffer);
return Status;
}