]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFsp2Pkg: Fixed potentially NULL pointer accessing
authorChasel, Chiu <chasel.chiu@intel.com>
Fri, 26 Oct 2018 07:12:33 +0000 (15:12 +0800)
committerChasel, Chiu <chasel.chiu@intel.com>
Mon, 29 Oct 2018 03:24:58 +0000 (11:24 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1280

When copying IDT table in SecMain, the pointer might be
NULL so added the check to fix it.

Test: Verified on internal platform and boots successfully.

Cc: Jiewen Yao <Jiewen.yao@intel.com>
Cc: Desimone Nathaniel L <nathaniel.l.desimone@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
IntelFsp2Pkg/FspSecCore/SecMain.c

index f319c68cc56067a3d265a30ba9edd1249367b2f4..70460a3c8befc298546949be0ddab4d05349cd0b 100644 (file)
@@ -100,7 +100,7 @@ SecStartup (
   // |-------------------|---->  TempRamBase\r
   IdtTableInStack.PeiService  = NULL;\r
   AsmReadIdtr (&IdtDescriptor);\r
-  if ((IdtDescriptor.Base == 0) && (IdtDescriptor.Limit == 0xFFFF)) {\r
+  if (IdtDescriptor.Base == 0) {\r
     ExceptionHandler = FspGetExceptionHandler(mIdtEntryTemplate);\r
     for (Index = 0; Index < FixedPcdGet8(PcdFspMaxInterruptSupported); Index ++) {\r
       CopyMem ((VOID*)&IdtTableInStack.IdtTable[Index], (VOID*)&ExceptionHandler, sizeof (UINT64));\r
@@ -113,8 +113,9 @@ SecStartup (
       // ERROR: IDT table size from boot loader is larger than FSP can support, DeadLoop here!\r
       //\r
       CpuDeadLoop();\r
+    } else {\r
+      CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *) IdtDescriptor.Base, IdtSize);\r
     }\r
-    CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *) IdtDescriptor.Base, IdtSize);\r
   }\r
   IdtDescriptor.Base  = (UINTN) &IdtTableInStack.IdtTable;\r
   IdtDescriptor.Limit = (UINT16)(IdtSize - 1);\r