]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SourceLevelDebugPkg/DebugAgent: Check PcdDebugPortHandleBufferSize
authorJeff Fan <jeff.fan@intel.com>
Thu, 4 Jun 2015 05:34:46 +0000 (05:34 +0000)
committervanjeff <vanjeff@Edk2>
Thu, 4 Jun 2015 05:34:46 +0000 (05:34 +0000)
Check PcdDebugPortHandleBufferSize before allocate buffer.
PeriodicMode is BOOLEAN type, needn't to use == TRUE in if condition.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17558 6f19259b-4bc3-4df7-8a09-765794883524

SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c

index fba41eecb71f98da5dffc0e0db18709d176f5edf..20b6a370d6bb104aabd1849ea1c0818812567cca 100644 (file)
@@ -657,7 +657,7 @@ InitializeDebugAgentPhase2 (
   MailboxLocation = GetLocationSavedMailboxPointerInIdtEntry ();\r
   Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);\r
   BufferSize = PcdGet16(PcdDebugPortHandleBufferSize);\r
-  if (Phase2Context->InitFlag == DEBUG_AGENT_INIT_PEI) {\r
+  if (Phase2Context->InitFlag == DEBUG_AGENT_INIT_PEI && BufferSize != 0) {\r
     NewDebugPortHandle = (UINT64)(UINTN)AllocateCopyPool (BufferSize, DebugPortHandle);\r
   } else {\r
     NewDebugPortHandle = (UINT64)(UINTN)DebugPortHandle;\r
index 72db534844987ec986fa31a1c33cc3113358be4f..4e4e1f536cdf0c0144c76156fb499a862c9870d9 100644 (file)
@@ -282,7 +282,7 @@ InitializeDebugAgent (
     //\r
     GetApicTimerState (NULL, &PeriodicMode, NULL);\r
     TimerCycle = GetApicTimerInitCount ();\r
-    if (PeriodicMode != TRUE || TimerCycle == 0) {\r
+    if (!PeriodicMode || TimerCycle == 0) {\r
       InitializeDebugTimer (NULL, FALSE);\r
       DisableApicTimerInterrupt ();\r
     }\r