diff options
author | Brendan Jackman <Brendan.JackMan@arm.com> | 2014-05-14 16:39:43 +0000 |
---|---|---|
committer | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-05-14 16:39:43 +0000 |
commit | 1aaa6f61a55a4db594d264ab8c0b0c9ddac1110e (patch) | |
tree | 820b697b4b409775df047b92227c9e9e574e57d9 /ArmPkg/Library/BdsLib | |
parent | 48ef4e4276fcd748f10f9a12f8dad6cc3c62ee01 (diff) | |
download | edk2-platforms-1aaa6f61a55a4db594d264ab8c0b0c9ddac1110e.tar.xz |
ArmPkg/BdsLib: Fix allocating kernel buffer in TFTP
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Brendan Jackman <Brendan.JackMan@arm.com>
Reviewed-By: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15527 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPkg/Library/BdsLib')
-rw-r--r-- | ArmPkg/Library/BdsLib/BdsFilePath.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/ArmPkg/Library/BdsLib/BdsFilePath.c b/ArmPkg/Library/BdsLib/BdsFilePath.c index 487bd7654c..90be9c1e11 100644 --- a/ArmPkg/Library/BdsLib/BdsFilePath.c +++ b/ArmPkg/Library/BdsLib/BdsFilePath.c @@ -756,7 +756,6 @@ BdsTftpLoadImage ( EFI_STATUS Status;
EFI_PXE_BASE_CODE_PROTOCOL *Pxe;
UINT64 TftpBufferSize;
- VOID* TftpBuffer;
EFI_IP_ADDRESS ServerIp;
IPv4_DEVICE_PATH* IPv4DevicePathNode;
FILEPATH_DEVICE_PATH* FilePathDevicePath;
@@ -838,16 +837,21 @@ BdsTftpLoadImage ( }
// Allocate a buffer to hold the whole file.
- TftpBuffer = AllocatePool (TftpBufferSize);
- if (TftpBuffer == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
+ Status = gBS->AllocatePages (
+ Type,
+ EfiBootServicesCode,
+ EFI_SIZE_TO_PAGES (TftpBufferSize),
+ Image
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "Failed to allocate space for kernel image: %r\n", Status));
goto EXIT;
}
Status = Pxe->Mtftp (
Pxe,
EFI_PXE_BASE_CODE_TFTP_READ_FILE,
- TftpBuffer,
+ (VOID *)(UINTN)*Image,
FALSE,
&TftpBufferSize,
NULL,
@@ -857,9 +861,8 @@ BdsTftpLoadImage ( FALSE
);
if (EFI_ERROR (Status)) {
- FreePool (TftpBuffer);
- } else if (ImageSize != NULL) {
- *Image = (UINTN)TftpBuffer;
+ gBS->FreePages (*Image, EFI_SIZE_TO_PAGES (TftpBufferSize));
+ } else {
*ImageSize = (UINTN)TftpBufferSize;
}
|