mirror of https://github.com/acidanthera/audk.git
ShellPkg/UefiHandleParsingLib.c: Handle memory allocation failure
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
This commit is contained in:
parent
d758f80971
commit
aa3276c171
|
@ -727,8 +727,9 @@ DriverEfiVersionProtocolDumpInformation(
|
||||||
ASSERT_EFI_ERROR(Status);
|
ASSERT_EFI_ERROR(Status);
|
||||||
|
|
||||||
RetVal = AllocateZeroPool(VersionStringSize);
|
RetVal = AllocateZeroPool(VersionStringSize);
|
||||||
ASSERT(RetVal != NULL);
|
if (RetVal != NULL) {
|
||||||
UnicodeSPrint(RetVal, VersionStringSize, L"0x%08x", DriverEfiVersion->FirmwareVersion);
|
UnicodeSPrint (RetVal, VersionStringSize, L"0x%08x", DriverEfiVersion->FirmwareVersion);
|
||||||
|
}
|
||||||
return (RetVal);
|
return (RetVal);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -2217,10 +2218,11 @@ InternalShellInitHandleList(
|
||||||
}
|
}
|
||||||
for (mHandleList.NextIndex = 1 ; mHandleList.NextIndex <= HandleCount ; mHandleList.NextIndex++){
|
for (mHandleList.NextIndex = 1 ; mHandleList.NextIndex <= HandleCount ; mHandleList.NextIndex++){
|
||||||
ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));
|
ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));
|
||||||
ASSERT(ListWalker != NULL);
|
if (ListWalker != NULL) {
|
||||||
ListWalker->TheHandle = HandleBuffer[mHandleList.NextIndex-1];
|
ListWalker->TheHandle = HandleBuffer[mHandleList.NextIndex - 1];
|
||||||
ListWalker->TheIndex = mHandleList.NextIndex;
|
ListWalker->TheIndex = mHandleList.NextIndex;
|
||||||
InsertTailList(&mHandleList.List.Link,&ListWalker->Link);
|
InsertTailList (&mHandleList.List.Link, &ListWalker->Link);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
FreePool(HandleBuffer);
|
FreePool(HandleBuffer);
|
||||||
return (EFI_SUCCESS);
|
return (EFI_SUCCESS);
|
||||||
|
@ -2288,7 +2290,9 @@ ConvertHandleToHandleIndex(
|
||||||
FreePool (ProtocolBuffer);
|
FreePool (ProtocolBuffer);
|
||||||
|
|
||||||
ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));
|
ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));
|
||||||
ASSERT(ListWalker != NULL);
|
if (ListWalker == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
ListWalker->TheHandle = TheHandle;
|
ListWalker->TheHandle = TheHandle;
|
||||||
ListWalker->TheIndex = mHandleList.NextIndex++;
|
ListWalker->TheIndex = mHandleList.NextIndex++;
|
||||||
InsertTailList(&mHandleList.List.Link,&ListWalker->Link);
|
InsertTailList(&mHandleList.List.Link,&ListWalker->Link);
|
||||||
|
@ -2415,7 +2419,10 @@ ParseHandleDatabaseByRelationshipWithType (
|
||||||
}
|
}
|
||||||
|
|
||||||
*HandleType = AllocateZeroPool (*HandleCount * sizeof (UINTN));
|
*HandleType = AllocateZeroPool (*HandleCount * sizeof (UINTN));
|
||||||
ASSERT(*HandleType != NULL);
|
if (*HandleType == NULL) {
|
||||||
|
SHELL_FREE_NON_NULL (*HandleBuffer);
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
DriverBindingHandleIndex = -1;
|
DriverBindingHandleIndex = -1;
|
||||||
for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {
|
for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {
|
||||||
|
@ -2671,26 +2678,26 @@ ParseHandleDatabaseByRelationship (
|
||||||
// Allocate a handle buffer for the number of handles that matched the attributes in Mask
|
// Allocate a handle buffer for the number of handles that matched the attributes in Mask
|
||||||
//
|
//
|
||||||
*MatchingHandleBuffer = AllocateZeroPool ((*MatchingHandleCount +1)* sizeof (EFI_HANDLE));
|
*MatchingHandleBuffer = AllocateZeroPool ((*MatchingHandleCount +1)* sizeof (EFI_HANDLE));
|
||||||
ASSERT(*MatchingHandleBuffer != NULL);
|
if (*MatchingHandleBuffer != NULL) {
|
||||||
|
for (HandleIndex = 0, *MatchingHandleCount = 0
|
||||||
for (HandleIndex = 0,*MatchingHandleCount = 0
|
; HandleIndex < HandleCount
|
||||||
; HandleIndex < HandleCount
|
; HandleIndex++
|
||||||
; HandleIndex++
|
) {
|
||||||
){
|
//
|
||||||
//
|
// Fill the allocated buffer with the handles that matched the attributes in Mask
|
||||||
// Fill the allocated buffer with the handles that matched the attributes in Mask
|
//
|
||||||
//
|
if ((HandleType[HandleIndex] & Mask) == Mask) {
|
||||||
if ((HandleType[HandleIndex] & Mask) == Mask) {
|
(*MatchingHandleBuffer)[(*MatchingHandleCount)++] = HandleBuffer[HandleIndex];
|
||||||
(*MatchingHandleBuffer)[(*MatchingHandleCount)++] = HandleBuffer[HandleIndex];
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Make the last one NULL
|
// Make the last one NULL
|
||||||
//
|
//
|
||||||
(*MatchingHandleBuffer)[*MatchingHandleCount] = NULL;
|
(*MatchingHandleBuffer)[*MatchingHandleCount] = NULL;
|
||||||
|
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
} // *MatchingHandleBuffer != NULL (IF)
|
||||||
} // MacthingHandleBuffer == NULL (ELSE)
|
} // MacthingHandleBuffer == NULL (ELSE)
|
||||||
} // *MatchingHandleCount == 0 (ELSE)
|
} // *MatchingHandleCount == 0 (ELSE)
|
||||||
} // no error on ParseHandleDatabaseByRelationshipWithType
|
} // no error on ParseHandleDatabaseByRelationshipWithType
|
||||||
|
|
Loading…
Reference in New Issue