Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,10 +773,7 @@ FvIsBeingProcessed (
}

KnownHandle = AllocateZeroPool (sizeof (KNOWN_HANDLE));
if (KnownHandle == NULL) {
ASSERT (KnownHandle != NULL);
return NULL;
}
ASSERT (KnownHandle != NULL);

KnownHandle->Signature = KNOWN_HANDLE_SIGNATURE;
KnownHandle->Handle = FvHandle;
Expand Down Expand Up @@ -853,7 +850,6 @@ CoreFvToDevicePath (
@retval EFI_ALREADY_STARTED The driver has already been started. Only one
DriverName may be active in the system at any one
time.
@retval EFI_OUT_OF_RESOURCES If memory could not be allocated for the DriverEntry.

**/
EFI_STATUS
Expand All @@ -871,11 +867,7 @@ CoreAddToDriverList (
// NULL or FALSE.
//
DriverEntry = AllocateZeroPool (sizeof (EFI_CORE_DRIVER_ENTRY));
if (DriverEntry == NULL) {
ASSERT (DriverEntry != NULL);
return EFI_OUT_OF_RESOURCES;
}

ASSERT (DriverEntry != NULL);
if (Type == EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {
DriverEntry->IsFvImage = TRUE;
}
Expand Down Expand Up @@ -1058,15 +1050,13 @@ CoreProcessFvImageFile (
//
if (gSecurity != NULL) {
FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, FileName);
Status = gSecurity->FileAuthenticationState (
gSecurity,
AuthenticationStatus,
FvFileDevicePath
);
if (FvFileDevicePath != NULL) {
Status = gSecurity->FileAuthenticationState (
gSecurity,
AuthenticationStatus,
FvFileDevicePath
);
FreePool (FvFileDevicePath);
} else {
Status = EFI_OUT_OF_RESOURCES;
}

if (Status != EFI_SUCCESS) {
Expand Down
41 changes: 7 additions & 34 deletions MdeModulePkg/Core/Dxe/Gcd/Gcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,7 @@ CoreDumpGcdMemorySpaceMap (
}

Status = CoreGetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
if (!((Status == EFI_SUCCESS) && (MemorySpaceMap != NULL))) {
ASSERT ((Status == EFI_SUCCESS) && (MemorySpaceMap != NULL));
return;
}
ASSERT (Status == EFI_SUCCESS && MemorySpaceMap != NULL);

if (InitialMap) {
DEBUG ((DEBUG_GCD, "GCD:Initial GCD Memory Space Map\n"));
Expand Down Expand Up @@ -217,10 +214,7 @@ CoreDumpGcdIoSpaceMap (
}

Status = CoreGetIoSpaceMap (&NumberOfDescriptors, &IoSpaceMap);
if (!((Status == EFI_SUCCESS) && (IoSpaceMap != NULL))) {
ASSERT ((Status == EFI_SUCCESS) && (IoSpaceMap != NULL));
return;
}
ASSERT (Status == EFI_SUCCESS && IoSpaceMap != NULL);

if (InitialMap) {
DEBUG ((DEBUG_GCD, "GCD:Initial GCD I/O Space Map\n"));
Expand Down Expand Up @@ -776,14 +770,13 @@ CoreConvertSpace (
Map = &mGcdIoSpaceMap;
} else {
ASSERT (FALSE);
return EFI_NOT_FOUND;
}

//
// Search for the list of descriptors that cover the range BaseAddress to BaseAddress+Length
//
Status = CoreSearchGcdMapEntry (BaseAddress, Length, &StartLink, &EndLink, Map);
if (EFI_ERROR (Status) || ((StartLink == NULL) || (EndLink == NULL))) {
if (EFI_ERROR (Status)) {
Status = EFI_UNSUPPORTED;

goto Done;
Expand Down Expand Up @@ -1191,7 +1184,6 @@ CoreAllocateSpace (
Map = &mGcdIoSpaceMap;
} else {
ASSERT (FALSE);
return EFI_NOT_FOUND;
}

Found = FALSE;
Expand Down Expand Up @@ -1359,12 +1351,6 @@ CoreAllocateSpace (
// Convert/Insert the list of descriptors from StartLink to EndLink
//
Link = StartLink;
if ((Link == NULL) || (EndLink == NULL)) {
ASSERT (Link != NULL);
ASSERT (EndLink != NULL);
goto Done;
}

while (Link != EndLink->ForwardLink) {
Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
CoreInsertGcdMapEntry (Link, Entry, *BaseAddress, Length, TopEntry, BottomEntry);
Expand Down Expand Up @@ -2665,22 +2651,15 @@ CoreInitializeGcdServices (
// Get the number of address lines in the I/O and Memory space for the CPU
//
CpuHob = GetFirstHob (EFI_HOB_TYPE_CPU);
if (CpuHob == NULL) {
ASSERT (CpuHob != NULL);
return EFI_OUT_OF_RESOURCES;
}

ASSERT (CpuHob != NULL);
SizeOfMemorySpace = CpuHob->SizeOfMemorySpace;
SizeOfIoSpace = CpuHob->SizeOfIoSpace;

//
// Initialize the GCD Memory Space Map
//
Entry = AllocateCopyPool (sizeof (EFI_GCD_MAP_ENTRY), &mGcdMemorySpaceMapEntryTemplate);
if (Entry == NULL) {
ASSERT (Entry != NULL);
return EFI_OUT_OF_RESOURCES;
}
ASSERT (Entry != NULL);

Entry->EndAddress = LShiftU64 (1, SizeOfMemorySpace) - 1;

Expand All @@ -2692,10 +2671,7 @@ CoreInitializeGcdServices (
// Initialize the GCD I/O Space Map
//
Entry = AllocateCopyPool (sizeof (EFI_GCD_MAP_ENTRY), &mGcdIoSpaceMapEntryTemplate);
if (Entry == NULL) {
ASSERT (Entry != NULL);
return EFI_OUT_OF_RESOURCES;
}
ASSERT (Entry != NULL);

Entry->EndAddress = LShiftU64 (1, SizeOfIoSpace) - 1;

Expand Down Expand Up @@ -2921,10 +2897,7 @@ CoreInitializeGcdServices (
(UINTN)PhitHob->EfiFreeMemoryBottom - (UINTN)(*HobStart),
*HobStart
);
if (NewHobList == NULL) {
ASSERT (NewHobList != NULL);
return EFI_OUT_OF_RESOURCES;
}
ASSERT (NewHobList != NULL);

*HobStart = NewHobList;
gHobList = NewHobList;
Expand Down
2 changes: 1 addition & 1 deletion MdeModulePkg/Core/Dxe/Hand/Handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ CoreOpenProtocol (
// Keep Interface unmodified in case of any Error
// except EFI_ALREADY_STARTED and EFI_UNSUPPORTED.
//
if ((!EFI_ERROR (Status) || (Status == EFI_ALREADY_STARTED)) && (Prot != NULL)) {
if (!EFI_ERROR (Status) || (Status == EFI_ALREADY_STARTED)) {
//
// According to above logic, if 'Prot' is NULL, then the 'Status' must be
// EFI_UNSUPPORTED. Here the 'Status' is not EFI_UNSUPPORTED, so 'Prot'
Expand Down
10 changes: 1 addition & 9 deletions MdeModulePkg/Core/Dxe/Image/Image.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,7 @@ PeCoffEmuProtocolNotify (
}

Entry = AllocateZeroPool (sizeof (*Entry));
if (Entry == NULL) {
ASSERT (Entry != NULL);
break;
}
ASSERT (Entry != NULL);

Entry->Emulator = Emulator;
Entry->MachineType = Entry->Emulator->MachineType;
Expand Down Expand Up @@ -1258,11 +1255,6 @@ CoreLoadImageCommon (
// LoadFile () may cause the device path of the Handle be updated.
//
OriginalFilePath = AppendDevicePath (DevicePathFromHandle (DeviceHandle), Node);
if (OriginalFilePath == NULL) {
Image = NULL;
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,11 +1276,8 @@ CoreUpdateProfileFree (
}
}

if ((DriverInfoData == NULL) || (AllocInfoData == NULL)) {
ASSERT (DriverInfoData != NULL);
ASSERT (AllocInfoData != NULL);
return EFI_NOT_FOUND;
}
ASSERT (DriverInfoData != NULL);
ASSERT (AllocInfoData != NULL);

Found = TRUE;

Expand Down
14 changes: 3 additions & 11 deletions MdeModulePkg/Core/Dxe/Mem/Page.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,7 @@ CoreFreeMemoryMapStack (
//
Entry = AllocateMemoryMapEntry ();

// If entry allocation failed once, it is unlikely to succeed moving forward
// However, we can try since we're in the middle of moving list nodes
if (Entry == NULL) {
ASSERT (Entry != NULL);
continue;
}
ASSERT (Entry);

//
// Update to proper entry
Expand Down Expand Up @@ -881,7 +876,7 @@ CoreConvertPagesEx (
}
}

if ((Link == &gMemoryMap) || (Entry == NULL)) {
if (Link == &gMemoryMap) {
DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: failed to find range %lx - %lx\n", Start, End));
return EFI_NOT_FOUND;
}
Expand All @@ -903,11 +898,8 @@ CoreConvertPagesEx (
// if that's all we've got
//
RangeEnd = End;
if (Entry == NULL) {
ASSERT (Entry != NULL);
return EFI_NOT_FOUND;
}

ASSERT (Entry != NULL);
if (Entry->End < End) {
RangeEnd = Entry->End;
}
Expand Down
4 changes: 0 additions & 4 deletions MdeModulePkg/Core/Dxe/Mem/Pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,6 @@ CoreAllocatePoolI (
NoPages = EFI_SIZE_TO_PAGES (Size) + EFI_SIZE_TO_PAGES (Granularity) - 1;
NoPages &= ~(UINTN)(EFI_SIZE_TO_PAGES (Granularity) - 1);
Head = CoreAllocatePoolPagesI (PoolType, NoPages, Granularity, NeedGuard);
if (Head == NULL) {
return NULL;
}

if (NeedGuard) {
Head = AdjustPoolHeadA ((EFI_PHYSICAL_ADDRESS)(UINTN)Head, NoPages, Size);
}
Expand Down
12 changes: 2 additions & 10 deletions MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,7 @@ InstallMemoryAttributesTable (

do {
MemoryMap = AllocatePool (MemoryMapSize);
if (MemoryMap == NULL) {
ASSERT (MemoryMap != NULL);
return;
}
ASSERT (MemoryMap != NULL);

Status = CoreGetMemoryMapWithSeparatedImageSection (
&MemoryMapSize,
Expand Down Expand Up @@ -182,12 +179,7 @@ InstallMemoryAttributesTable (
// Allocate MemoryAttributesTable
//
MemoryAttributesTable = AllocatePool (sizeof (EFI_MEMORY_ATTRIBUTES_TABLE) + DescriptorSize * RuntimeEntryCount);
if (MemoryAttributesTable == NULL) {
ASSERT (MemoryAttributesTable != NULL);
FreePool (MemoryMapStart);
return;
}

ASSERT (MemoryAttributesTable != NULL);
MemoryAttributesTable->Version = EFI_MEMORY_ATTRIBUTES_TABLE_VERSION;
MemoryAttributesTable->NumberOfEntries = RuntimeEntryCount;
MemoryAttributesTable->DescriptorSize = (UINT32)DescriptorSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,7 @@ CreateGuidedExtractionRpnEvent (
// Allocate new event structure and context
//
Context = AllocatePool (sizeof (RPN_EVENT_CONTEXT));
if (Context == NULL) {
ASSERT (Context != NULL);
return;
}
ASSERT (Context != NULL);

Context->ChildNode = ChildNode;
Context->ParentStream = ParentStream;
Expand Down
6 changes: 1 addition & 5 deletions MdeModulePkg/Core/DxeIplPeim/DxeLoad.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,7 @@ InstallIplPermanentMemoryPpis (
//
if (ExtractHandlerNumber > 0) {
GuidPpi = (EFI_PEI_PPI_DESCRIPTOR *)AllocatePool (ExtractHandlerNumber * sizeof (EFI_PEI_PPI_DESCRIPTOR));
if (GuidPpi == NULL) {
ASSERT (GuidPpi != NULL);
return EFI_OUT_OF_RESOURCES;
}

ASSERT (GuidPpi != NULL);
while (ExtractHandlerNumber-- > 0) {
GuidPpi->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
GuidPpi->Ppi = (VOID *)&mCustomGuidedSectionExtractionPpi;
Expand Down
20 changes: 4 additions & 16 deletions MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,7 @@ Split2MPageTo4K (
AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64;

PageTableEntry = AllocatePageTableMemory (1);
if (PageTableEntry == NULL) {
ASSERT (PageTableEntry != NULL);
return;
}
ASSERT (PageTableEntry != NULL);

//
// Fill in 2M page entry.
Expand Down Expand Up @@ -391,10 +388,7 @@ Split1GPageTo2M (
AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64;

PageDirectoryEntry = AllocatePageTableMemory (1);
if (PageDirectoryEntry == NULL) {
ASSERT (PageDirectoryEntry != NULL);
return;
}
ASSERT (PageDirectoryEntry != NULL);

//
// Fill in 1G page entry.
Expand Down Expand Up @@ -523,10 +517,7 @@ SetPageTablePoolReadOnly (
ASSERT (Level > 1);

NewPageTable = AllocatePageTableMemory (1);
if (NewPageTable == NULL) {
ASSERT (NewPageTable != NULL);
return;
}
ASSERT (NewPageTable != NULL);

PhysicalAddress = PageAttr & LevelMask[Level];
for (EntryIndex = 0;
Expand Down Expand Up @@ -771,10 +762,7 @@ CreateIdentityMappingPageTables (
));

BigPageAddress = (UINTN)AllocatePageTableMemory (TotalPagesNum);
if (BigPageAddress == 0) {
ASSERT (BigPageAddress != 0);
return 0;
}
ASSERT (BigPageAddress != 0);

//
// By architecture only one PageMapLevel4 exists - so lets allocate storage for it.
Expand Down
17 changes: 3 additions & 14 deletions MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,7 @@ DiscoverPeimsAndOrderWithApriori (
TempFileHandles = AllocatePool (
sizeof (EFI_PEI_FILE_HANDLE) * (Private->TempPeimCount + TEMP_FILE_GROWTH_STEP)
);
if (TempFileHandles == NULL) {
ASSERT (TempFileHandles != NULL);
return;
}

ASSERT (TempFileHandles != NULL);
CopyMem (
TempFileHandles,
Private->TempFileHandles,
Expand All @@ -462,11 +458,7 @@ DiscoverPeimsAndOrderWithApriori (
TempFileGuid = AllocatePool (
sizeof (EFI_GUID) * (Private->TempPeimCount + TEMP_FILE_GROWTH_STEP)
);
if (TempFileGuid == NULL) {
ASSERT (TempFileGuid != NULL);
return;
}

ASSERT (TempFileGuid != NULL);
CopyMem (
TempFileGuid,
Private->TempFileGuid,
Expand Down Expand Up @@ -1918,10 +1910,7 @@ PeiDispatcher (

for (FvCount = Private->CurrentPeimFvCount; FvCount < Private->FvCount; FvCount++) {
CoreFvHandle = FindNextCoreFvHandle (Private, FvCount);
if (CoreFvHandle == NULL) {
ASSERT (CoreFvHandle != NULL);
continue;
}
ASSERT (CoreFvHandle != NULL);

//
// If the FV has corresponding EFI_PEI_FIRMWARE_VOLUME_PPI instance, then dispatch it.
Expand Down
Loading
Loading