]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFsp2WrapperPkg: Add error handling for possible NULL ptr dereference
authorHao Wu <hao.a.wu@intel.com>
Thu, 30 Jun 2016 01:13:24 +0000 (09:13 +0800)
committerHao Wu <hao.a.wu@intel.com>
Fri, 1 Jul 2016 00:50:39 +0000 (08:50 +0800)
Possible NULL pointer dereference for FspmHeaderPtr/FspsHeaderPtr in
module FspmWrapperPeim/FspsWrapperPeim.

Add error handling codes to avoid this issue.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Giri P Mudusuru <giri.p.mudusuru@intel.com>
IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c

index 6144ad7f41e6f3e54731fa8dae0dae8b58254dd9..c98513e41b4123739974158ae6079c4a75dcd323 100644 (file)
@@ -68,6 +68,11 @@ PeiFspMemoryInit (
   // Copy default FSP-M UPD data from Flash\r
   //\r
   FspmHeaderPtr = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspmBaseAddress));\r
+  DEBUG ((DEBUG_INFO, "FspmHeaderPtr - 0x%x\n", FspmHeaderPtr));\r
+  if (FspmHeaderPtr == NULL) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
   FspmUpdDataPtr = (FSPM_UPD_COMMON *)AllocateZeroPool ((UINTN)FspmHeaderPtr->CfgRegionSize);\r
   ASSERT (FspmUpdDataPtr != NULL);\r
   SourceData = (UINTN *)((UINTN)FspmHeaderPtr->ImageBase + (UINTN)FspmHeaderPtr->CfgRegionOffset);\r
index 7a65ad7f6138d1265615d3778663b9d808a2bad0..c9236908c82ada4e8cb308ba048497fc4e9c3e72 100644 (file)
@@ -241,6 +241,11 @@ PeiMemoryDiscoveredNotify (
   // Copy default FSP-S UPD data from Flash\r
   //\r
   FspsHeaderPtr = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspsBaseAddress));\r
+  DEBUG ((DEBUG_INFO, "FspsHeaderPtr - 0x%x\n", FspsHeaderPtr));\r
+  if (FspsHeaderPtr == NULL) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
   FspsUpdDataPtr = (FSPS_UPD_COMMON *)AllocateZeroPool ((UINTN)FspsHeaderPtr->CfgRegionSize);\r
   ASSERT (FspsUpdDataPtr != NULL);\r
   SourceData = (UINTN *)((UINTN)FspsHeaderPtr->ImageBase + (UINTN)FspsHeaderPtr->CfgRegionOffset);\r