{\r
EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;\r
EFI_DEVICE_PATH_PROTOCOL *OrigDevicePathNode;\r
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePathNode;\r
EFI_HANDLE Handle;\r
EFI_GUID *FvNameGuid;\r
EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol;\r
//\r
// Init local variable\r
//\r
+ TempDevicePathNode = NULL;\r
FvNameGuid = NULL;\r
FileInfo = NULL;\r
FileHandle = NULL;\r
//\r
Status = Volume->OpenVolume (Volume, &FileHandle);\r
if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Duplicate the device path to avoid the access to unaligned device path node.\r
+ // Because the device path consists of one or more FILE PATH MEDIA DEVICE PATH\r
+ // nodes, It assures the fields in device path nodes are 2 byte aligned.\r
+ //\r
+ TempDevicePathNode = DuplicateDevicePath (DevicePathNode);\r
+ if (TempDevicePathNode == NULL) {\r
+ FileHandle->Close (FileHandle);\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Finish;\r
+ }\r
//\r
// Parse each MEDIA_FILEPATH_DP node. There may be more than one, since the\r
// directory information and filename can be seperate. The goal is to inch\r
// our way down each device path node and close the previous node\r
//\r
+ DevicePathNode = TempDevicePathNode;\r
while (!IsDevicePathEnd (DevicePathNode) && !EFI_ERROR (Status)) {\r
if (DevicePathType (DevicePathNode) != MEDIA_DEVICE_PATH ||\r
DevicePathSubType (DevicePathNode) != MEDIA_FILEPATH_DP) {\r
}\r
}\r
//\r
- // Close the file and Free FileInfo since we are done\r
+ // Close the file and Free FileInfo and TempDevicePathNode since we are done\r
// \r
if (FileInfo != NULL) {\r
FreePool (FileInfo);\r
if (FileHandle != NULL) {\r
FileHandle->Close (FileHandle);\r
}\r
+ FreePool (TempDevicePathNode);\r
}\r
}\r
goto Finish;\r