From 14238a61c8c17668c705c46c38cf8d7186880bfa Mon Sep 17 00:00:00 2001 From: oliviermartin Date: Wed, 2 May 2012 20:17:36 +0000 Subject: [PATCH] ArmPlatformPkg/Bds: Fixed Memory Corruption when updating the path of a Linux initrd Signed-off-by: Olivier Martin git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13264 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPlatformPkg/Bds/BootMenu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c index e7e475dfc1..ecd1d60f40 100644 --- a/ArmPlatformPkg/Bds/BootMenu.c +++ b/ArmPlatformPkg/Bds/BootMenu.c @@ -354,7 +354,8 @@ BootMenuUpdateBootOption ( ARM_BDS_LOADER_ARGUMENTS* BootArguments; CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX]; CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX]; - EFI_DEVICE_PATH* DevicePath; + EFI_DEVICE_PATH *DevicePath; + EFI_DEVICE_PATH *TempInitrdPath; ARM_BDS_LOADER_TYPE BootType; ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData; ARM_BDS_LINUX_ARGUMENTS* LinuxArguments; @@ -423,11 +424,13 @@ BootMenuUpdateBootOption ( if (InitrdPathNode != NULL) { // Duplicate Linux kernel Device Path - DevicePath = DuplicateDevicePath (BootOption->FilePathList); + TempInitrdPath = DuplicateDevicePath (BootOption->FilePathList); // Replace Linux kernel Node by EndNode - SetDevicePathEndNode (GetLastDevicePathNode (DevicePath)); + SetDevicePathEndNode (GetLastDevicePathNode (TempInitrdPath)); // Append the Device Path node to the select device path - InitrdPath = AppendDevicePathNode (DevicePath, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode); + InitrdPath = AppendDevicePathNode (TempInitrdPath, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNode); + FreePool (TempInitrdPath); + InitrdSize = GetDevicePathSize (InitrdPath); } else { InitrdPath = NULL; } -- 2.39.2