diff options
author | Dandan Bi <dandan.bi@intel.com> | 2018-06-27 12:37:19 +0800 |
---|---|---|
committer | Eric Dong <eric.dong@intel.com> | 2018-06-28 19:46:07 +0800 |
commit | 981b7edc0e2f984c62608e9c5c5702ad106fa764 (patch) | |
tree | 8ffff6e07cd10ce7666dec9f0dfed0b1faa63e3f /MdeModulePkg/Library | |
parent | ecd0f8b12f90a603d61c8263134599f7911bbc07 (diff) | |
download | edk2-981b7edc0e2f984c62608e9c5c5702ad106fa764.zip edk2-981b7edc0e2f984c62608e9c5c5702ad106fa764.tar.gz edk2-981b7edc0e2f984c62608e9c5c5702ad106fa764.tar.bz2 |
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')
3 files changed, 32 insertions, 17 deletions
diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 57a14e8..5798c89 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -1111,14 +1111,13 @@ InsertFpdtRecord ( case PERF_EVENTSIGNAL_END_ID:
case PERF_CALLBACK_START_ID:
case PERF_CALLBACK_END_ID:
- if (String == NULL) {
+ if (String == NULL || Guid == NULL) {
return EFI_INVALID_PARAMETER;
}
- //
- // Cache the event guid in string event record when PcdEdkiiFpdtStringRecordEnableOnly == TRUE
- //
- CopyGuid (&ModuleGuid, Guid);
StringPtr = String;
+ if (AsciiStrLen (String) == 0) {
+ StringPtr = "unknown name";
+ }
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE;
FpdtRecordPtr.DualGuidStringEvent->Header.Length = sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD);
@@ -1196,7 +1195,14 @@ InsertFpdtRecord ( FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
- CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
+ if (Guid != NULL) {
+ //
+ // Cache the event guid in string event record.
+ //
+ CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, Guid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
+ } else {
+ CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
+ }
if (AsciiStrLen (StringPtr) == 0) {
StringPtr = "unknown name";
}
diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c index 8a65a2a..808a635 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;
diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index 0c00fb5..f18c3fb 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -649,14 +649,13 @@ InsertFpdtRecord ( case PERF_EVENTSIGNAL_END_ID:
case PERF_CALLBACK_START_ID:
case PERF_CALLBACK_END_ID:
- if (String == NULL) {
+ if (String == NULL || Guid == NULL) {
return EFI_INVALID_PARAMETER;
}
- //
- // Cache the event guid in string event record when PcdEdkiiFpdtStringRecordEnableOnly == TRUE
- //
- CopyGuid (&ModuleGuid, Guid);
StringPtr = String;
+ if (AsciiStrLen (String) == 0) {
+ StringPtr = "unknown name";
+ }
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE;
FpdtRecordPtr.DualGuidStringEvent->Header.Length = sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD);
@@ -734,7 +733,14 @@ InsertFpdtRecord ( FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
- CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
+ if (Guid != NULL) {
+ //
+ // Cache the event guid in string event record.
+ //
+ CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, Guid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
+ } else {
+ CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
+ }
if (AsciiStrLen (StringPtr) == 0) {
StringPtr = "unknown name";
}
|