summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Library/PeiPerformanceLib
diff options
context:
space:
mode:
authorDandan Bi <dandan.bi@intel.com>2018-06-27 12:37:19 +0800
committerEric Dong <eric.dong@intel.com>2018-06-28 19:46:07 +0800
commit981b7edc0e2f984c62608e9c5c5702ad106fa764 (patch)
tree8ffff6e07cd10ce7666dec9f0dfed0b1faa63e3f /MdeModulePkg/Library/PeiPerformanceLib
parentecd0f8b12f90a603d61c8263134599f7911bbc07 (diff)
downloadedk2-981b7edc0e2f984c62608e9c5c5702ad106fa764.tar.gz
edk2-981b7edc0e2f984c62608e9c5c5702ad106fa764.tar.bz2
edk2-981b7edc0e2f984c62608e9c5c5702ad106fa764.zip
MdeModulePkg/PerformanceLib: Add NULL pointer check
1. Add NULL pointer check for the "Guid" parameter when handle FPDT_DUAL_GUID_STRING_EVENT_TYPE. 2. Make the code logic in DxeCore/SmmCore/PeiPerformanceLib aligned when handle FPDT_DUAL_GUID_STRING_EVENT_TYPE. Cc: Liming Gao <liming.gao@intel.com> Cc: Hao Wu <hao.a.wu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Diffstat (limited to 'MdeModulePkg/Library/PeiPerformanceLib')
-rw-r--r--MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
index 8a65a2a747..808a63501e 100644
--- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
+++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
@@ -77,10 +77,10 @@ GetFpdtRecordPtr (
//
PeiFirmwarePerformance = (UINT8*)GET_GUID_HOB_DATA (GuidHob);
*PeiPerformanceLogHeader = (FPDT_PEI_EXT_PERF_HEADER *)PeiFirmwarePerformance;
- if (!(*PeiPerformanceLogHeader)->HobIsFull && (*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize > (UINTN)(PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE)) {
+ if (!(*PeiPerformanceLogHeader)->HobIsFull && (*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize > (PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE)) {
(*PeiPerformanceLogHeader)->HobIsFull = TRUE;
}
- if (!(*PeiPerformanceLogHeader)->HobIsFull && (*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize <= (UINTN)(PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE)) {
+ if (!(*PeiPerformanceLogHeader)->HobIsFull && (*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize <= (PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE)) {
FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(PeiFirmwarePerformance + sizeof (FPDT_PEI_EXT_PERF_HEADER) + (*PeiPerformanceLogHeader)->SizeOfAllEntries);
break;
}
@@ -423,9 +423,11 @@ InsertFpdtRecord (
case PERF_EVENTSIGNAL_END_ID:
case PERF_CALLBACK_START_ID:
case PERF_CALLBACK_END_ID:
- if (String != NULL && AsciiStrLen (String) != 0) {
- StringPtr = String;
- } else {
+ if (String == NULL || Guid == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ StringPtr = String;
+ if (AsciiStrLen (String) == 0) {
StringPtr = "unknown name";
}
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
@@ -436,6 +438,7 @@ InsertFpdtRecord (
FpdtRecordPtr.DualGuidStringEvent->Timestamp = TimeStamp;
CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid1, ModuleGuid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid1));
CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid2, Guid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid2));
+ CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DualGuidStringEvent->String, StringPtr, &FpdtRecordPtr.DualGuidStringEvent->Header.Length);
}
break;