MdeModulePkg/UefiBootManagerLib: Avoid buggy USB short-form expanding

When a load option points to a physical UsbIo controller, whose
device path contains UsbClass or UsbWwid node, old logic
unconditionally treats it as a short-form device path and expands
it. But the expanding gets the exactly same device path, and the
device path is passed to BmGetNextLoadOptionDevicePath() which
then passes this device path to BmExpandUsbDevicePath() again.
This causes a infinite recursion.

The patch avoids the USB short-form expanding when the device path
points to a physical UsbIo controller.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
This commit is contained in:
Ruiyu Ni 2017-04-19 17:16:27 +08:00
parent 52cad7d0d8
commit 21e359dcca
1 changed files with 26 additions and 17 deletions

View File

@ -1546,6 +1546,14 @@ BmGetNextLoadOptionDevicePath (
//
return BmExpandUriDevicePath (FilePath, FullPath);
} else {
Node = FilePath;
Status = gBS->LocateDevicePath (&gEfiUsbIoProtocolGuid, &Node, &Handle);
if (EFI_ERROR (Status)) {
//
// Only expand the USB WWID/Class device path
// when FilePath doesn't point to a physical UsbIo controller.
// Otherwise, infinite recursion will happen.
//
for (Node = FilePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {
if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) &&
((DevicePathSubType (Node) == MSG_USB_CLASS_DP) || (DevicePathSubType (Node) == MSG_USB_WWID_DP))) {
@ -1568,6 +1576,7 @@ BmGetNextLoadOptionDevicePath (
return BmExpandUsbDevicePath (FilePath, FullPath, Node);
}
}
}
//
// For the below cases, FilePath only expands to one Full path.