fix: [Common] Dereference null return TempSmbiosStrTbl (#1951)

If the function actually returns a null value,
a null pointer dereference will occur.
In InitializeSmbiosInfo: Return value of function which returns
null is dereferenced without checking (CWE-476)

Signed-off-by: Randy <randy.lin@intel.com>
This commit is contained in:
randylintw 2023-07-15 03:19:01 +08:00 committed by GitHub
parent a8637fecd2
commit 6a818eb039
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 25 additions and 2 deletions

View File

@ -154,7 +154,10 @@ InitializeSmbiosInfo (
PlatformId = GetPlatformId ();
TempSmbiosStrTbl = (SMBIOS_TYPE_STRINGS *) AllocateTemporaryMemory (0);
VerInfoTbl = GetVerInfoPtr ();
if (TempSmbiosStrTbl == NULL) {
DEBUG ((DEBUG_ERROR, "TempSmbiosStrTbl allocation failed\n"));
return EFI_OUT_OF_RESOURCES;
}
//
// SMBIOS_TYPE_BIOS_INFORMATION
//

View File

@ -567,6 +567,9 @@ InitializeSmbiosInfo (
Index = 0;
PlatformId = GetPlatformId ();
TempSmbiosStrTbl = (SMBIOS_TYPE_STRINGS *) AllocateTemporaryMemory (0);
if (TempSmbiosStrTbl == NULL) {
return EFI_OUT_OF_RESOURCES;
}
VerInfoTbl = GetVerInfoPtr ();
//

View File

@ -743,6 +743,9 @@ InitializeSmbiosInfo (
Index = 0;
PlatformId = GetPlatformId ();
TempSmbiosStrTbl = (SMBIOS_TYPE_STRINGS *) AllocateTemporaryMemory (0);
if (TempSmbiosStrTbl == NULL) {
return EFI_OUT_OF_RESOURCES;
}
VerInfoTbl = GetVerInfoPtr ();
//

View File

@ -736,6 +736,9 @@ InitializeSmbiosInfo (
Index = 0;
PlatformId = GetPlatformId ();
TempSmbiosStrTbl = (SMBIOS_TYPE_STRINGS *) AllocateTemporaryMemory (0);
if (TempSmbiosStrTbl == NULL) {
return EFI_OUT_OF_RESOURCES;
}
VerInfoTbl = GetVerInfoPtr ();
//

View File

@ -484,8 +484,10 @@ InitializeSmbiosInfo (
Index = 0;
TempSmbiosStrTbl = (SMBIOS_TYPE_STRINGS *) AllocateTemporaryMemory (0);
if (TempSmbiosStrTbl == NULL) {
return EFI_OUT_OF_RESOURCES;
}
VerInfoTbl = GetVerInfoPtr ();
//
// SMBIOS_TYPE_BIOS_INFORMATION
//

View File

@ -67,6 +67,9 @@ InitializeSmbiosInfo (
if (FeaturePcdGet (PcdSmbiosEnabled)) {
Index = 0;
TempSmbiosStrTbl = (SMBIOS_TYPE_STRINGS *) AllocateTemporaryMemory (0);
if (TempSmbiosStrTbl == NULL) {
return EFI_OUT_OF_RESOURCES;
}
VerInfoTbl = GetVerInfoPtr ();
//

View File

@ -313,6 +313,9 @@ InitializeSmbiosInfo (
Index = 0;
TempSmbiosStrTbl = (SMBIOS_TYPE_STRINGS *) AllocateTemporaryMemory (0);
if (TempSmbiosStrTbl == NULL) {
return EFI_OUT_OF_RESOURCES;
}
VerInfoTbl = GetVerInfoPtr ();
//

View File

@ -540,6 +540,9 @@ InitializeSmbiosInfo (
Index = 0;
TempSmbiosStrTbl = (SMBIOS_TYPE_STRINGS *) AllocateTemporaryMemory (0);
if (TempSmbiosStrTbl == NULL) {
return EFI_OUT_OF_RESOURCES;
}
VerInfoTbl = GetVerInfoPtr ();
//