ArmPlatformPkg/Bds: Fixed Memory Corruption when updating the path of a Linux initrd

Signed-off-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13264 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin 2012-05-02 20:17:36 +00:00
parent 1c8f9a70d0
commit 14238a61c8
1 changed files with 7 additions and 4 deletions

View File

@ -355,6 +355,7 @@ BootMenuUpdateBootOption (
CHAR16 BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];
CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX];
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;
}