public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch][edk2-platforms/devel-IntelAtomProcessorE3900 3Add NULL checking for some pointers
@ 2018-08-23  5:32 Guo, Mang
  0 siblings, 0 replies; only message in thread
From: Guo, Mang @ 2018-08-23  5:32 UTC (permalink / raw)
  To: edk2-devel@lists.01.org

Cc: David Wei <david.wei@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Guo Mang <mang.guo@intel.com>
Reviewed-by:  David Wei <david.wei@intel.com>
---
 .../SmBiosMiscDxe/MiscSystemManufacturerFunction.c       | 16 +++++++++-------
 .../DxeSmbiosProcessorLib/DxeSmbiosProcessorLib.c        |  7 ++++++-
 .../Library/PeiFspPolicyInitLib/PeiFspSaPolicyInitLib.c  | 10 +++++++++-
 .../FspsWrapperPeim/FspsWrapperPeim.c                    |  6 +++++-
 4 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Smbios/SmBiosMiscDxe/MiscSystemManufacturerFunction.c b/Platform/BroxtonPlatformPkg/Common/Features/Smbios/SmBiosMiscDxe/MiscSystemManufacturerFunction.c
index 0000e12..1c611f5 100644
--- a/Platform/BroxtonPlatformPkg/Common/Features/Smbios/SmBiosMiscDxe/MiscSystemManufacturerFunction.c
+++ b/Platform/BroxtonPlatformPkg/Common/Features/Smbios/SmBiosMiscDxe/MiscSystemManufacturerFunction.c
@@ -418,13 +418,15 @@ AddSmbiosManuCallback (
   //
   //ForType1InputData->SystemUuid.Data1 = PcdGet32 (PcdProductSerialNumber);
   //ForType1InputData->SystemUuid.Data4[0] = PcdGet8 (PcdEmmcManufacturerId);
-  ForType1InputData->SystemUuid.Data1 = (UINT32)MacAddressString [0] + (((UINT32)MacAddressString [1]) << 16);
-  ForType1InputData->SystemUuid.Data2 = (UINT16)MacAddressString [2];
-  ForType1InputData->SystemUuid.Data3 = (UINT16)MacAddressString [3];
-  ForType1InputData->SystemUuid.Data4[0] = (UINT8)MacAddressString [4];
-  ForType1InputData->SystemUuid.Data4[1] = (UINT8)(MacAddressString [4] >> 8);
-  ForType1InputData->SystemUuid.Data4[2] = (UINT8)MacAddressString [5];
-  ForType1InputData->SystemUuid.Data4[3] = (UINT8)(MacAddressString [5] >> 8);
+  if ( MacAddressString != NULL) {
+    ForType1InputData->SystemUuid.Data1 = (UINT32)MacAddressString [0] + (((UINT32)MacAddressString [1]) << 16);
+    ForType1InputData->SystemUuid.Data2 = (UINT16)MacAddressString [2];
+    ForType1InputData->SystemUuid.Data3 = (UINT16)MacAddressString [3];
+    ForType1InputData->SystemUuid.Data4[0] = (UINT8)MacAddressString [4];
+    ForType1InputData->SystemUuid.Data4[1] = (UINT8)(MacAddressString [4] >> 8);
+    ForType1InputData->SystemUuid.Data4[2] = (UINT8)MacAddressString [5];
+    ForType1InputData->SystemUuid.Data4[3] = (UINT8)(MacAddressString [5] >> 8);
+ }
   
   CopyMem ((UINT8 *) (&SmbiosRecord->Uuid),&ForType1InputData->SystemUuid,16);
 
diff --git a/Platform/BroxtonPlatformPkg/Common/Library/DxeSmbiosProcessorLib/DxeSmbiosProcessorLib.c b/Platform/BroxtonPlatformPkg/Common/Library/DxeSmbiosProcessorLib/DxeSmbiosProcessorLib.c
index f182c8d..e4d157e 100644
--- a/Platform/BroxtonPlatformPkg/Common/Library/DxeSmbiosProcessorLib/DxeSmbiosProcessorLib.c
+++ b/Platform/BroxtonPlatformPkg/Common/Library/DxeSmbiosProcessorLib/DxeSmbiosProcessorLib.c
@@ -1,7 +1,7 @@
 /** @file
   Smbios Processor Information Driver which produces Smbios type 4 and 7 tables.
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
@@ -276,6 +276,11 @@ InstallSmbiosCacheInfo (
       // Allocate full record, including fixed data region, and string buffer region.
       //
       SmbiosType7Record = (SMBIOS_TABLE_TYPE7 *) AllocateZeroPool (sizeof (SMBIOS_TABLE_TYPE7) + StringBufferLength);
+      if (SmbiosType7Record == NULL) {
+        DEBUG ((DEBUG_ERROR, "Fail to allocate memory\n"));
+        return EFI_OUT_OF_RESOURCES;
+      }
+
       SmbiosStringBufferPtr = ((UINT8 *) SmbiosType7Record) + sizeof (SMBIOS_TABLE_TYPE7);
 
       //
diff --git a/Platform/BroxtonPlatformPkg/Common/Library/PeiFspPolicyInitLib/PeiFspSaPolicyInitLib.c b/Platform/BroxtonPlatformPkg/Common/Library/PeiFspPolicyInitLib/PeiFspSaPolicyInitLib.c
index c76f433..aa41981 100644
--- a/Platform/BroxtonPlatformPkg/Common/Library/PeiFspPolicyInitLib/PeiFspSaPolicyInitLib.c
+++ b/Platform/BroxtonPlatformPkg/Common/Library/PeiFspPolicyInitLib/PeiFspSaPolicyInitLib.c
@@ -1,7 +1,7 @@
 /** @file
   Implementation of Fsp SA Policy Initialization.
 
-  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
@@ -133,6 +133,10 @@ PeiFspSaPolicyInitPreMem (
 
   VariableSize = sizeof (SYSTEM_CONFIGURATION);
   SystemConfiguration = AllocateZeroPool (VariableSize);
+  if (SystemConfiguration == NULL) {
+    DEBUG ((DEBUG_ERROR, "Fail to allocate memory\n"));
+    return EFI_OUT_OF_RESOURCES;
+  }
 
   Status = VariableServices->GetVariable (
                                VariableServices,
@@ -212,6 +216,10 @@ PeiFspSaPolicyInit (
 
   VariableSize = sizeof (SYSTEM_CONFIGURATION);
   SystemConfiguration = AllocateZeroPool (VariableSize);
+  if (SystemConfiguration == NULL) {
+    DEBUG ((DEBUG_ERROR, "Fail to allocate memory\n"));
+    return EFI_OUT_OF_RESOURCES;
+  }
 
   Status = VariableServices->GetVariable (
                                VariableServices,
diff --git a/Platform/BroxtonPlatformPkg/Common/SampleCode/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c b/Platform/BroxtonPlatformPkg/Common/SampleCode/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
index 7343b77..5f1f13a 100644
--- a/Platform/BroxtonPlatformPkg/Common/SampleCode/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
+++ b/Platform/BroxtonPlatformPkg/Common/SampleCode/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
@@ -3,7 +3,7 @@
   register TemporaryRamDonePpi to call TempRamExit API, and register MemoryDiscoveredPpi
   notify to call FspSiliconInit API.
 
-  Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
@@ -228,6 +228,10 @@ PeiMasterBootModeNotify (
   // Copy default FSP-S UPD data from Flash
   //
   FspsHeaderPtr = (FSP_INFO_HEADER *) FspFindFspHeader (PcdGet32 (PcdFspsBaseAddress));
+  if (FspsHeaderPtr == NULL) {
+    DEBUG ((DEBUG_ERROR, "Fail to get Fsps Header\n"));
+    return EFI_UNSUPPORTED;
+  }
   FspsHeaderPtr->ImageBase = (UINT32) (PcdGet32 (PcdFspsBaseAddress));
 
   FspsUpdDataPtr = (FSPS_UPD_COMMON *) AllocateZeroPool ((UINTN) FspsHeaderPtr->CfgRegionSize);
-- 
2.10.1.windows.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-08-23  5:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-23  5:32 [Patch][edk2-platforms/devel-IntelAtomProcessorE3900 3Add NULL checking for some pointers Guo, Mang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox