From f3fc9d8dc987f9b78aeefd5800833c4c5bb8acf0 Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Thu, 22 May 2014 07:38:40 +0000 Subject: [PATCH] Remove the RT attribute for HDDP variable and validate the variable content before using it. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Reviewed-by: Chao Zhang git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15545 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Library/GenericBdsLib/BdsBoot.c | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c index 508bd6e9ac..de69a04b04 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c @@ -2524,11 +2524,28 @@ BdsExpandPartitionPartialDevicePathToFull ( // If exist, search the front path which point to partition node in the variable instants. // If fail to find or HD_BOOT_DEVICE_PATH_VARIABLE_NAME not exist, reconnect all and search in all system // - CachedDevicePath = BdsLibGetVariableAndSize ( - HD_BOOT_DEVICE_PATH_VARIABLE_NAME, - &gHdBootDevicePathVariablGuid, - &CachedDevicePathSize - ); + GetVariable2 ( + HD_BOOT_DEVICE_PATH_VARIABLE_NAME, + &gHdBootDevicePathVariablGuid, + (VOID **) &CachedDevicePath, + &CachedDevicePathSize + ); + + // + // Delete the invalid HD_BOOT_DEVICE_PATH_VARIABLE_NAME variable. + // + if ((CachedDevicePath != NULL) && !IsDevicePathValid (CachedDevicePath, CachedDevicePathSize)) { + FreePool (CachedDevicePath); + CachedDevicePath = NULL; + Status = gRT->SetVariable ( + HD_BOOT_DEVICE_PATH_VARIABLE_NAME, + &gHdBootDevicePathVariablGuid, + 0, + 0, + NULL + ); + ASSERT_EFI_ERROR (Status); + } if (CachedDevicePath != NULL) { TempNewDevicePath = CachedDevicePath; @@ -2591,7 +2608,7 @@ BdsExpandPartitionPartialDevicePathToFull ( Status = gRT->SetVariable ( HD_BOOT_DEVICE_PATH_VARIABLE_NAME, &gHdBootDevicePathVariablGuid, - EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, GetDevicePathSize (CachedDevicePath), CachedDevicePath ); @@ -2690,7 +2707,7 @@ BdsExpandPartitionPartialDevicePathToFull ( Status = gRT->SetVariable ( HD_BOOT_DEVICE_PATH_VARIABLE_NAME, &gHdBootDevicePathVariablGuid, - EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, GetDevicePathSize (CachedDevicePath), CachedDevicePath ); -- 2.39.2