summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorMike Maslenkin <mike.maslenkin@gmail.com>2024-04-27 12:14:36 +0300
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-08-26 05:32:42 +0000
commit1cc0fae8d9e2681fc6a33e5602ce8368809f9465 (patch)
tree29e150522a2313bd0e8e05c234c6b8343ea520d6 /MdeModulePkg
parentb158dad150bf02879668f72ce306445250838201 (diff)
downloadedk2-1cc0fae8d9e2681fc6a33e5602ce8368809f9465.tar.gz
edk2-1cc0fae8d9e2681fc6a33e5602ce8368809f9465.tar.bz2
edk2-1cc0fae8d9e2681fc6a33e5602ce8368809f9465.zip
MdeModulePkg/RamDiskDxe: fix memory leak on error path.
This patch fixes a leak of memory allocated for the RAM disk in cases when an error occurred while reading contents of a file from disk or RamDiskRegister() returned some error condition. Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c
index 60cf3c8c4a..2dac121c47 100644
--- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c
+++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c
@@ -404,7 +404,8 @@ HiiCreateRamDisk (
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- return EFI_DEVICE_ERROR;
+ Status = EFI_DEVICE_ERROR;
+ goto ErrorExit;
}
}
@@ -431,7 +432,7 @@ HiiCreateRamDisk (
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- return Status;
+ goto ErrorExit;
}
//
@@ -442,6 +443,10 @@ HiiCreateRamDisk (
PrivateData->CreateMethod = RamDiskCreateHii;
return EFI_SUCCESS;
+
+ErrorExit:
+ gBS->FreePool (StartingAddr);
+ return Status;
}
/**