- CachedDevicePath = BdsLibGetVariableAndSize (\r
- HD_BOOT_DEVICE_PATH_VARIABLE_NAME,\r
- &gHdBootDevicePathVariablGuid,\r
- &CachedDevicePathSize\r
- );\r
+ GetVariable2 (\r
+ HD_BOOT_DEVICE_PATH_VARIABLE_NAME,\r
+ &gHdBootDevicePathVariablGuid,\r
+ (VOID **) &CachedDevicePath,\r
+ &CachedDevicePathSize\r
+ );\r
+\r
+ //\r
+ // Delete the invalid HD_BOOT_DEVICE_PATH_VARIABLE_NAME variable.\r
+ //\r
+ if ((CachedDevicePath != NULL) && !IsDevicePathValid (CachedDevicePath, CachedDevicePathSize)) {\r
+ FreePool (CachedDevicePath);\r
+ CachedDevicePath = NULL;\r
+ Status = gRT->SetVariable (\r
+ HD_BOOT_DEVICE_PATH_VARIABLE_NAME,\r
+ &gHdBootDevicePathVariablGuid,\r
+ 0,\r
+ 0,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r