diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c index e767e6b147..34ccc79528 100644 --- a/IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c +++ b/IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c @@ -104,11 +104,10 @@ MemoryStatusCodeReportWorker ( PacketIndex = 0; // - // Journal GUID'ed HOBs to find empty record entry. if found, then save status code in it. - // otherwise, create a new GUID'ed HOB. + // Journal GUID'ed HOBs to find empty record entry. // Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid); - while (Hob.Raw != NULL) { + while ((Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw)) != NULL) { PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid); // @@ -124,17 +123,14 @@ MemoryStatusCodeReportWorker ( // PacketIndex++; - Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw); + Hob.Raw = GET_NEXT_HOB (Hob); } if (Record == NULL) { // - // No available entry found, so create new packet. + // No available entry found // - PacketHeader = CreateMemoryStatusCodePacket (PacketIndex); - - Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1); - Record = &Record[PacketHeader->RecordIndex++]; + return EFI_OUT_OF_RESOURCES; } Record->CodeType = CodeType; diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/DataHubStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/DataHubStatusCodeWorker.c index 5c1616e14b..92ca20a2ed 100644 --- a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/DataHubStatusCodeWorker.c +++ b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/DataHubStatusCodeWorker.c @@ -24,7 +24,7 @@ EFI_EVENT mLogDataHubEvent; // // Cache data hub protocol. // -EFI_DATA_HUB_PROTOCOL *mDataHubProtocol; +EFI_DATA_HUB_PROTOCOL *mDataHubProtocol = NULL; /** @@ -189,6 +189,7 @@ DataHubStatusCodeReportWorker ( BASE_LIST Marker; CHAR8 *Format; UINTN CharCount; + EFI_STATUS Status; // // Use atom operation to avoid the reentant of report. @@ -205,6 +206,13 @@ DataHubStatusCodeReportWorker ( return EFI_DEVICE_ERROR; } + if (mDataHubProtocol == NULL) { + Status = DataHubStatusCodeInitializeWorker (); + if (EFI_ERROR (Status)) { + return Status; + } + } + Record = AcquireRecordBuffer (); if (Record == NULL) { // @@ -358,7 +366,10 @@ DataHubStatusCodeInitializeWorker ( NULL, (VOID **) &mDataHubProtocol ); - ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + mDataHubProtocol = NULL; + return Status; + } // // Create a Notify Event to log data in Data Hub diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.c b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.c index cb2c271124..8807bbac4e 100644 --- a/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.c +++ b/IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.c @@ -226,8 +226,7 @@ InitializationDispatcherWorker ( ASSERT_EFI_ERROR (Status); } if (FeaturePcdGet (PcdStatusCodeUseDataHub)) { - Status = DataHubStatusCodeInitializeWorker (); - ASSERT_EFI_ERROR (Status); + DataHubStatusCodeInitializeWorker (); } if (FeaturePcdGet (PcdStatusCodeUseOEM)) { //