From fa2c75b0e7f36ceceddf7c0b3e082d49ccc12419 Mon Sep 17 00:00:00 2001 From: kenlautner <85201046+kenlautner@users.noreply.github.com> Date: Fri, 1 Dec 2023 14:44:22 -0800 Subject: [PATCH] Added codeql fixes to DxeCorePerformanceLib.c (#636) ## Description Addressed some codeql errors in DxeCorePerformanceLib.c. Nothing functionally has changed as a null module name being returned is being accounted for already. - [ ] Impacts functionality? - **Functionality** - Does the change ultimately impact how firmware functions? - Examples: Add a new library, publish a new PPI, update an algorithm, ... - [ ] Impacts security? - **Security** - Does the change have a direct security impact on an application, flow, or firmware? - Examples: Crypto algorithm change, buffer overflow fix, parameter validation improvement, ... - [ ] Breaking change? - **Breaking change** - Will anyone consuming this change experience a break in build or boot behavior? - Examples: Add a new library class, move a module to a different repo, call a function in a new library class in a pre-existing module, ... - [ ] Includes tests? - **Tests** - Does the change include any explicit test code? - Examples: Unit tests, integration tests, robot tests, ... - [ ] Includes documentation? - **Documentation** - Does the change contain explicit documentation additions outside direct code modifications (and comments)? - Examples: Update readme file, add feature readme file, link to documentation on an a separate Web page, ... ## How This Was Tested Tested on an intel physical platform. ## Integration Instructions N/A --- .../DxeCorePerformanceLib.c | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 6da0fea971..38c52cc261 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -1047,7 +1047,13 @@ InsertFpdtRecord ( switch (PerfId) { case MODULE_START_ID: case MODULE_END_ID: - GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid); + // MU_CHANGE [BEGIN] - CodeQL change + Status = GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to get Module Info from Handle! Status = %r\n", Status)); + } + + // MU_CHANGE [END] - CodeQL change StringPtr = ModuleName; // // Cache the offset of start image start record and use to update the start image end record if needed. @@ -1083,7 +1089,13 @@ InsertFpdtRecord ( case MODULE_LOADIMAGE_START_ID: case MODULE_LOADIMAGE_END_ID: - GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid); + // MU_CHANGE [BEGIN] - CodeQL change + Status = GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to get Module Info from Handle! Status = %r\n", Status)); + } + + // MU_CHANGE [END] - CodeQL change StringPtr = ModuleName; if (PerfId == MODULE_LOADIMAGE_START_ID) { mLoadImageCount++; @@ -1126,7 +1138,13 @@ InsertFpdtRecord ( case MODULE_DB_SUPPORT_END_ID: case MODULE_DB_STOP_START_ID: case MODULE_DB_STOP_END_ID: - GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid); + // MU_CHANGE [BEGIN] - CodeQL change + Status = GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to get Module Info from Handle! Status = %r\n", Status)); + } + + // MU_CHANGE [END] - CodeQL change StringPtr = ModuleName; if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE; @@ -1141,7 +1159,13 @@ InsertFpdtRecord ( break; case MODULE_DB_END_ID: - GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid); + // MU_CHANGE [BEGIN] - CodeQL change + Status = GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to get Module Info from Handle! Status = %r\n", Status)); + } + + // MU_CHANGE [END] - CodeQL change StringPtr = ModuleName; if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) { FpdtRecordPtr.GuidQwordStringEvent->Header.Type = FPDT_GUID_QWORD_STRING_EVENT_TYPE;