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
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
//\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