summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2025-05-12 16:33:13 -0700
committerLiming Gao <gaoliming@byosoft.com.cn>2025-07-17 15:36:06 +0800
commitcb85c4deefea9f893c511c54c1911cc84d816a57 (patch)
tree514bf8b6a517f594169bbc99435936e404551721
parent4cb3e8d46721c7d3410cc347e3262a64421e913c (diff)
downloadedk2-cb85c4deefea9f893c511c54c1911cc84d816a57.zip
edk2-cb85c4deefea9f893c511c54c1911cc84d816a57.tar.gz
edk2-cb85c4deefea9f893c511c54c1911cc84d816a57.tar.bz2
MdeModulePkg: FvSimpleFileSystemDxe cumulative codeql issues.
Running Codeql on MdeModulePkg/Universal/FvSimpleFileSystemDxe drivers results in codeql errors stemming from missing null tests. Signed-off-by: Aaron Pop <aaronpop@microsoft.com> Co-authored-by: Michael Kubacki <michael.kubacki@microsoft.com> Co-authored-by: Taylor Beebe <tabeebe@microsoft.com> Co-authored-by: pohanch <125842322+pohanch@users.noreply.github.com> Co-authored-by: kenlautner <85201046+kenlautner@users.noreply.github.com> Co-authored-by: Oliver Smith-Denny <osde@linux.microsoft.com> Co-authored-by: Sean Brogan <sean.brogan@microsoft.com> Co-authored-by: Aaron <aaronpop@microsoft>
-rw-r--r--MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c4
-rw-r--r--MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c5
2 files changed, 8 insertions, 1 deletions
diff --git a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
index 0252db1..42ab3f1 100644
--- a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
+++ b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
@@ -562,6 +562,10 @@ FvSimpleFileSystemOpen (
// NewFileNameLength = FileNameLength + 1 + 4 = (Number of non-null character) + (file extension) + (a null character)
NewFileNameLength = FileNameLength + 1 + 4;
FileNameWithExtension = AllocatePool (NewFileNameLength * 2);
+ if (FileNameWithExtension == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
StrCpyS (FileNameWithExtension, NewFileNameLength, FileName);
StrCatS (FileNameWithExtension, NewFileNameLength, L".EFI");
diff --git a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c
index 3f96407..5d7fdaa 100644
--- a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c
+++ b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c
@@ -450,7 +450,10 @@ FvSimpleFileSystemDriverStart (
// Create an instance
//
Instance = AllocateZeroPool (sizeof (FV_FILESYSTEM_INSTANCE));
- ASSERT (Instance != NULL);
+ if (Instance == NULL) {
+ ASSERT (Instance != NULL);
+ return EFI_OUT_OF_RESOURCES;
+ }
Instance->Root = NULL;
Instance->FvProtocol = FvProtocol;