X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FUefiDevicePathLib%2FUefiDevicePathLib.c;h=e05736bbb7bebff8afbf10321f609b3ebed7540a;hp=31a0462f079beaffd47e9a8ed8fac8572b9da1e9;hb=28c73f6ef7fc6cb1803d80761002ec2a7330d833;hpb=df569f61e3806ec8dbeef9c89123f5b223720c07 diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c index 31a0462f07..e05736bbb7 100644 --- a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c +++ b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c @@ -496,24 +496,26 @@ FileDevicePath ( UINTN Size; FILEPATH_DEVICE_PATH *FilePath; EFI_DEVICE_PATH_PROTOCOL *DevicePath; - EFI_DEVICE_PATH_PROTOCOL *FileDevicePathNode; + EFI_DEVICE_PATH_PROTOCOL *FileDevicePath; DevicePath = NULL; Size = StrSize (FileName); - FileDevicePathNode = CreateDeviceNode ( - MEDIA_DEVICE_PATH, - MEDIA_FILEPATH_DP, - (UINT16) (Size + SIZE_OF_FILEPATH_DEVICE_PATH) - ); - if (FileDevicePathNode != NULL) { - FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePathNode; + FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + EFI_END_DEVICE_PATH_LENGTH); + if (FileDevicePath != NULL) { + FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath; + FilePath->Header.Type = MEDIA_DEVICE_PATH; + FilePath->Header.SubType = MEDIA_FILEPATH_DP; CopyMem (&FilePath->PathName, FileName, Size); + SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH); + SetDevicePathEndNode (NextDevicePathNode (&FilePath->Header)); + if (Device != NULL) { DevicePath = DevicePathFromHandle (Device); } - DevicePath = AppendDevicePathNode (DevicePath, FileDevicePathNode); - FreePool (FileDevicePathNode); + + DevicePath = AppendDevicePath (DevicePath, FileDevicePath); + FreePool (FileDevicePath); } return DevicePath;