Resolve Klocwork issues in Payload & Platform
Klocwork scanning reported several issues in the PayloadPkg and Platform code folders, this commit aims to resolve all of the issues currently being reported in these folders. Signed-off-by: James Gutbub <james.gutbub@intel.com>
This commit is contained in:
parent
cc46751e0c
commit
327fbac532
|
@ -243,6 +243,7 @@ LoadCapsuleImage (
|
|||
CHAR16 FileName[MAX_FILE_LEN];
|
||||
EFI_HANDLE FileHandle;
|
||||
|
||||
FileHandle = NULL;
|
||||
HwPartHandle = NULL;
|
||||
Status = FindBootPartition (CapsuleInfo, &HwPartHandle);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
@ -273,9 +274,8 @@ LoadCapsuleImage (
|
|||
}
|
||||
|
||||
//
|
||||
// get capsule image size.
|
||||
// Get capsule image size.
|
||||
//
|
||||
FileHandle = NULL;
|
||||
*CapsuleImageSize = 0;
|
||||
*CapsuleImage = NULL;
|
||||
|
||||
|
|
|
@ -231,8 +231,10 @@ SecStartup (
|
|||
AddMeasurePointTimestamp (0x4000, TimeStamp);
|
||||
|
||||
// ACPI table
|
||||
SystemTableInfo = GetSystemTableInfo();
|
||||
ParseAcpiTableInfo ((UINT32)SystemTableInfo->AcpiTableBase);
|
||||
SystemTableInfo = GetSystemTableInfo ();
|
||||
if (SystemTableInfo != NULL) {
|
||||
ParseAcpiTableInfo ((UINT32)SystemTableInfo->AcpiTableBase);
|
||||
}
|
||||
|
||||
DEBUG_CODE_BEGIN ();
|
||||
// Initialize HOB/Stack region with known pattern so that the usage can be detected
|
||||
|
|
|
@ -49,7 +49,7 @@ EmmcSerialNumCheck (
|
|||
|
||||
// Compare serial number from the card and SPI flash
|
||||
if (AsciiStriCmp (LoaderPlatformInfo->SerialNumber, EmmcTuningData.SerialNumber) != 0) {
|
||||
AsciiStrCpyS (EmmcTuningData.SerialNumber, sizeof(EmmcTuningData.SerialNumber), LoaderPlatformInfo->SerialNumber);
|
||||
AsciiStrCpyS (EmmcTuningData.SerialNumber, sizeof(EmmcTuningData.SerialNumber), LoaderPlatformInfo->SerialNumber);
|
||||
|
||||
// Save new serial number into SPI flash
|
||||
Status = SetVariable ((CHAR8 *)mMmcDllStr, 0, sizeof (EMMC_TUNING_DATA), (VOID *)&EmmcTuningData);
|
||||
|
@ -112,14 +112,15 @@ SeedSanityCheck (
|
|||
ClearSeedHOB = FALSE;
|
||||
UseedCount = 0;
|
||||
DseedCount = 0;
|
||||
SeedListLen = 0;
|
||||
|
||||
OsBootOptionList = GetBootOptionList ();
|
||||
if ((OsBootOptionList == NULL) || (OsBootOptionList->OsBootOptionCount == 0)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
SeedListInfo = GetSeedListInfoHOB(&SeedListLen);
|
||||
if ((SeedListInfo == NULL) || (SeedListLen < 0)) {
|
||||
SeedListInfo = GetSeedListInfoHOB (&SeedListLen);
|
||||
if ((SeedListInfo == NULL) || (SeedListLen == 0)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@ -236,7 +237,7 @@ RpmbKeyProvisioning (
|
|||
|
||||
// Get Rpmb Key provisioning flag from Cfg Data
|
||||
GenCfgData = (GEN_CFG_DATA *) FindConfigDataByTag (CDATA_GEN_TAG);
|
||||
if (GenCfgData == NULL) {
|
||||
if (GenCfgData == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@ -250,10 +251,10 @@ RpmbKeyProvisioning (
|
|||
}
|
||||
|
||||
// Get manufacturing state
|
||||
Eom = ((LoaderPlatformInfo->HwState & HWSTATE_IN_MANUFACTURING_MODE) == 0) ?TRUE:FALSE;
|
||||
Eom = ((LoaderPlatformInfo->HwState & HWSTATE_IN_MANUFACTURING_MODE) == 0) ?TRUE:FALSE;
|
||||
|
||||
// Proceed further only if its in production mode and if the verified boot is enabled
|
||||
if((Eom) || ((LoaderPlatformInfo->LdrFeatures & FEATURE_VERIFIED_BOOT) == FEATURE_VERIFIED_BOOT)) {
|
||||
if((Eom) || ((LoaderPlatformInfo->LdrFeatures & FEATURE_VERIFIED_BOOT) == FEATURE_VERIFIED_BOOT)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -313,7 +313,7 @@ LoadLinuxFile (
|
|||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (FileInfo->Buf[0] == 0) {
|
||||
if ((FileInfo->Buf[0] == 0) && (ConfigFile != NULL)) {
|
||||
Ptr = ConfigFile + FileInfo->Pos;
|
||||
} else {
|
||||
Ptr = FileInfo->Buf + FileInfo->Pos;
|
||||
|
@ -390,10 +390,13 @@ GetTraditionalLinux (
|
|||
EFI_HANDLE FileHandle;
|
||||
BOOLEAN DefBootOption;
|
||||
|
||||
ConfigFile = NULL;
|
||||
ConfigFileSize = 0;
|
||||
DefBootOption = FALSE;
|
||||
Status = RETURN_NOT_FOUND;
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Try booting Linux from config file ...\n"));
|
||||
|
||||
DefBootOption = FALSE;
|
||||
Status = RETURN_NOT_FOUND;
|
||||
for (Index = 0; Index < (UINTN)(FeaturePcdGet (PcdGrubBootCfgEnabled) ? 2 : 1); Index++) {
|
||||
DEBUG ((DEBUG_INFO, "Checking %s\n",mConfigFileName[Index]));
|
||||
ConfigFile = NULL;
|
||||
|
@ -477,7 +480,7 @@ GetTraditionalLinux (
|
|||
|
||||
// Update command line
|
||||
LinuxImage->CmdFile.Size = LinuxBootCfg.MenuEntry[EntryIdx].Command.Len;
|
||||
if (LinuxImage->CmdFile.Size > 0) {
|
||||
if ((LinuxImage->CmdFile.Size > 0) && (ConfigFile != NULL)) {
|
||||
Ptr = (CHAR8 *)ConfigFile + LinuxBootCfg.MenuEntry[EntryIdx].Command.Pos;
|
||||
Ptr[LinuxImage->CmdFile.Size] = 0;
|
||||
LinuxImage->CmdFile.Addr = Ptr;
|
||||
|
|
|
@ -150,6 +150,7 @@ SpiLoadExternalConfigData (
|
|||
Address = 0;
|
||||
BlobSize = sizeof(CDATA_BLOB);
|
||||
Buffer = (UINT8 *)Dst;
|
||||
Base = 0;
|
||||
|
||||
CfgDataLoadSrc = PcdGet32 (PcdCfgDataLoadSource);
|
||||
|
||||
|
@ -197,10 +198,10 @@ SpiLoadExternalConfigData (
|
|||
if (CfgDataLoadSrc == FlashRegionPlatformData) {
|
||||
Status = SpiFlashRead (FlashRegionPlatformData, Address + BlobSize, SignedLen - BlobSize, Buffer + BlobSize);
|
||||
} else {
|
||||
CopyMem (Buffer + BlobSize, (VOID *)(Base + BlobSize), SignedLen - BlobSize);
|
||||
if (Base > 0) {
|
||||
CopyMem (Buffer + BlobSize, (VOID *)(Base + BlobSize), SignedLen - BlobSize);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue