mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
MdeModulePkg: Fix missing NULL tests
https://github.com/github/codeql/blob/codeql-cli-2.7.3/cpp/ql/src/Critical/MissingNullTest.qhelp For items which allocate memory, or get a pointer from another structure, it is important to validate that the pointers are not null before they are dereferenced. Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
This commit is contained in:
parent
dfd0edeb4e
commit
9b3ceeb254
3 changed files with 18 additions and 6 deletions
|
|
@ -168,13 +168,14 @@ UpdateBlocksAndVolumes (
|
|||
EFI_PEI_SERVICES **PeiServices;
|
||||
|
||||
IndexBlockDevice = 0;
|
||||
BlockIo2Ppi = NULL;
|
||||
BlockIoPpi = NULL;
|
||||
|
||||
//
|
||||
// Find out all Block Io Ppi instances within the system
|
||||
// Assuming all device Block Io Peims are dispatched already
|
||||
//
|
||||
for (BlockIoPpiInstance = 0; BlockIoPpiInstance < PEI_CD_EXPRESS_MAX_BLOCK_IO_PPI; BlockIoPpiInstance++) {
|
||||
BlockIo2Ppi = NULL;
|
||||
BlockIoPpi = NULL;
|
||||
if (BlockIo2) {
|
||||
Status = PeiServicesLocatePpi (
|
||||
&gEfiPeiVirtualBlockIo2PpiGuid,
|
||||
|
|
|
|||
|
|
@ -477,10 +477,16 @@ UpdateMainForm (
|
|||
// Init OpCode Handle
|
||||
//
|
||||
StartOpCodeHandle = HiiAllocateOpCodeHandle ();
|
||||
ASSERT (StartOpCodeHandle != NULL);
|
||||
if (StartOpCodeHandle == NULL) {
|
||||
ASSERT (StartOpCodeHandle != NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
EndOpCodeHandle = HiiAllocateOpCodeHandle ();
|
||||
ASSERT (EndOpCodeHandle != NULL);
|
||||
if (EndOpCodeHandle == NULL) {
|
||||
ASSERT (EndOpCodeHandle != NULL);
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
//
|
||||
// Create Hii Extend Label OpCode as the start opcode
|
||||
|
|
@ -552,8 +558,9 @@ UpdateMainForm (
|
|||
EndOpCodeHandle
|
||||
);
|
||||
|
||||
HiiFreeOpCodeHandle (StartOpCodeHandle);
|
||||
HiiFreeOpCodeHandle (EndOpCodeHandle);
|
||||
Exit:
|
||||
HiiFreeOpCodeHandle (StartOpCodeHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -167,7 +167,11 @@ RamDiskPublishNfit (
|
|||
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
|
||||
do {
|
||||
MemoryMap = (EFI_MEMORY_DESCRIPTOR *)AllocatePool (MemoryMapSize);
|
||||
ASSERT (MemoryMap != NULL);
|
||||
if (MemoryMap == NULL) {
|
||||
ASSERT (MemoryMap != NULL);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = gBS->GetMemoryMap (
|
||||
&MemoryMapSize,
|
||||
MemoryMap,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue