From b148591a8ce071b686aaadad398d599685f33487 Mon Sep 17 00:00:00 2001 From: oliviermartin Date: Thu, 9 Feb 2012 15:29:35 +0000 Subject: ArmPlatformPkg/Bds: Fixed memory leak git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12997 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPlatformPkg/Bds/Bds.c | 14 +++++++++++++- ArmPlatformPkg/Bds/BootOption.c | 13 ++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ArmPlatformPkg/Bds/Bds.c b/ArmPlatformPkg/Bds/Bds.c index 176311e8a2..8f7f9fdf7c 100644 --- a/ArmPlatformPkg/Bds/Bds.c +++ b/ArmPlatformPkg/Bds/Bds.c @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2011, ARM Limited. All rights reserved. +* Copyright (c) 2011-2012, ARM Limited. All rights reserved. * * This program and the accompanying materials * are licensed and made available under the terms and conditions of the BSD License @@ -196,6 +196,17 @@ InitializeConsole ( gST->StdErr = gST->ConOut; } + // Free Memory allocated for reading the UEFI Variables + if (ConOutDevicePaths) { + FreePool (ConOutDevicePaths); + } + if (ConInDevicePaths) { + FreePool (ConInDevicePaths); + } + if (ConErrDevicePaths) { + FreePool (ConErrDevicePaths); + } + return EFI_SUCCESS; } @@ -344,6 +355,7 @@ StartDefaultBootOnTimeout ( } // In case of success, we should not return from this call. } + FreePool (BootOrder); } } return EFI_SUCCESS; diff --git a/ArmPlatformPkg/Bds/BootOption.c b/ArmPlatformPkg/Bds/BootOption.c index d811c03ccc..3710178a43 100644 --- a/ArmPlatformPkg/Bds/BootOption.c +++ b/ArmPlatformPkg/Bds/BootOption.c @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2011, ARM Limited. All rights reserved. +* Copyright (c) 2011-2012, ARM Limited. All rights reserved. * * This program and the accompanying materials * are licensed and made available under the terms and conditions of the BSD License @@ -82,6 +82,8 @@ BootOptionStart ( Initrd, // Initrd (CHAR8*)(LinuxArguments + 1), FdtDevicePath); + + FreePool (FdtDevicePath); } } else { Status = BdsStartEfiApplication (mImageHandle, BootOption->FilePathList, BootOption->OptionalDataSize, BootOption->OptionalData); @@ -119,6 +121,8 @@ BootOptionList ( } } + FreePool (BootOrder); + return EFI_SUCCESS; } @@ -290,6 +294,11 @@ BootOptionCreate ( BootOrder ); + // We only free it if the UEFI Variable 'BootOrder' was already existing + if (BootOrderSize > sizeof(UINT16)) { + FreePool (BootOrder); + } + *BdsLoadOption = BootOption; return Status; } @@ -361,5 +370,7 @@ BootOptionDelete ( ); } + FreePool (BootOrder); + return EFI_SUCCESS; } -- cgit v1.2.3