]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/DevicePathLib: Fix FromText bug for multi-instance devicepath
authorRuiyu Ni <ruiyu.ni@intel.com>
Thu, 23 Mar 2017 05:09:45 +0000 (13:09 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Thu, 23 Mar 2017 05:11:32 +0000 (13:11 +0800)
UefiDevicePathLibConvertTextToDevicePath correctly detects when it
has hit a ',' splicing together multiple paths. However, the code
that tries to cope with it:
{code}
if (IsInstanceEnd) {
  DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (
                                   END_DEVICE_PATH_LENGTH);
  ASSERT (DeviceNode != NULL);
  SetDevicePathEndNode (DeviceNode);

  NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);
  FreePool (DevicePath);
  FreePool (DeviceNode);
  DevicePath = NewDevicePath;
}
{code}
causes a problem. The END node that's appended it the node for the
entire list. So when the node is appended in AppendDevicePathNode,
it winds up disappearing. This leads to the path
'PciRoot(0x0),PciRoot(0x0)' parsing as if 'PciRoot(0x0)/PciRoot(0x0)'
were specified. These are two very different things.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c

index a52cbef48f45b7a3c391a8d2de2e87f1495c5662..3c9df289b6d91a012ffdcb5cdd4baa4ef91a29b5 100644 (file)
@@ -3500,6 +3500,7 @@ UefiDevicePathLibConvertTextToDevicePath (
       DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r
       ASSERT (DeviceNode != NULL);\r
       SetDevicePathEndNode (DeviceNode);\r
+      DeviceNode->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;\r
 \r
       NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);\r
       FreePool (DevicePath);\r