From 3e710183d118ba84c32c46027bbc548c8766549d Mon Sep 17 00:00:00 2001 From: oliviermartin Date: Tue, 13 Sep 2011 09:03:10 +0000 Subject: ArmPlatformPkg/Bds: Fix the update of existing boot entries Variables were not initialized in the right order in the boot entry update function. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12335 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPlatformPkg/Bds/BootMenu.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'ArmPlatformPkg/Bds/BootMenu.c') diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c index 3bfe2f6152..3796f826f3 100644 --- a/ArmPlatformPkg/Bds/BootMenu.c +++ b/ArmPlatformPkg/Bds/BootMenu.c @@ -372,14 +372,16 @@ BootMenuUpdateBootOption ( LinuxArguments = &OptionalData->Arguments.LinuxArguments; CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize); - InitrdSize = GetUnalignedDevicePathSize ((EFI_DEVICE_PATH*)((LinuxArguments + 1) + CmdLineSize)); - Print(L"File path of the initrd: "); - Status = DeviceSupport->UpdateDevicePathNode ( - (EFI_DEVICE_PATH_PROTOCOL *)((UINTN)(LinuxArguments + 1) + CmdLineSize), &InitrdPathList, NULL, NULL); - if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) {// EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd - Status = EFI_ABORTED; - goto EXIT; + InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize); + if (InitrdSize > 0) { + Print(L"File path of the initrd: "); + Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((LinuxArguments + 1) + CmdLineSize), &InitrdPathList, NULL, NULL); + if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) {// EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd + Status = EFI_ABORTED; + goto EXIT; + } + InitrdSize = GetDevicePathSize (InitrdPathList); } Print(L"Arguments to pass to the binary: "); @@ -395,7 +397,6 @@ BootMenuUpdateBootOption ( } CmdLineSize = AsciiStrSize (CmdLine); - InitrdSize = GetDevicePathSize (InitrdPathList); BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool(sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize); BootArguments->LinuxArguments.CmdLineSize = CmdLineSize; @@ -407,6 +408,7 @@ BootMenuUpdateBootOption ( } Print(L"Description for this new Entry: "); + StrnCpy (BootDescription, BootOption->Description, BOOT_DEVICE_DESCRIPTION_MAX); Status = EditHIInputStr (BootDescription, BOOT_DEVICE_DESCRIPTION_MAX); if (EFI_ERROR(Status)) { Status = EFI_ABORTED; @@ -536,7 +538,7 @@ BootMenuMain ( EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol; ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData; UINTN CmdLineSize; - ARM_BDS_LOADER_TYPE LoaderType; + ARM_BDS_LOADER_TYPE LoaderType; Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol); if (EFI_ERROR(Status)) { -- cgit v1.2.3