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....@intel.com> CC: Ruiyu Ni <ruiyu...@intel.com> --- .../Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c | 2 +- SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c index fba41ee..20b6a37 100644 --- a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c +++ b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c @@ -657,7 +657,7 @@ InitializeDebugAgentPhase2 ( MailboxLocation = GetLocationSavedMailboxPointerInIdtEntry (); Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation); BufferSize = PcdGet16(PcdDebugPortHandleBufferSize); - if (Phase2Context->InitFlag == DEBUG_AGENT_INIT_PEI) { + if (Phase2Context->InitFlag == DEBUG_AGENT_INIT_PEI && BufferSize != 0) { NewDebugPortHandle = (UINT64)(UINTN)AllocateCopyPool (BufferSize, DebugPortHandle); } else { NewDebugPortHandle = (UINT64)(UINTN)DebugPortHandle; diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c index 72db534..4e4e1f5 100644 --- a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c +++ b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c @@ -282,7 +282,7 @@ InitializeDebugAgent ( // GetApicTimerState (NULL, &PeriodicMode, NULL); TimerCycle = GetApicTimerInitCount (); - if (PeriodicMode != TRUE || TimerCycle == 0) { + if (!PeriodicMode || TimerCycle == 0) { InitializeDebugTimer (NULL, FALSE); DisableApicTimerInterrupt (); } -- 1.9.5.msysgit.0 ------------------------------------------------------------------------------ _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel