public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Guo, Mang" <mang.guo@intel.com>
To: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: [Patch][edk2-platforms/devel-IntelAtomProcessorE3900 3Add NULL checking for some pointers
Date: Thu, 23 Aug 2018 05:32:53 +0000	[thread overview]
Message-ID: <22D2C85ED001C54AA20BFE3B0E4751D1526D396A@SHSMSX103.ccr.corp.intel.com> (raw)

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



                 reply	other threads:[~2018-08-23  5:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=22D2C85ED001C54AA20BFE3B0E4751D1526D396A@SHSMSX103.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox