//\r
return BmExpandUriDevicePath (FilePath, FullPath);\r
} else {\r
- for (Node = FilePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {\r
- if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) &&\r
- ((DevicePathSubType (Node) == MSG_USB_CLASS_DP) || (DevicePathSubType (Node) == MSG_USB_WWID_DP))) {\r
- break;\r
+ Node = FilePath;\r
+ Status = gBS->LocateDevicePath (&gEfiUsbIoProtocolGuid, &Node, &Handle);\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // Only expand the USB WWID/Class device path\r
+ // when FilePath doesn't point to a physical UsbIo controller.\r
+ // Otherwise, infinite recursion will happen.\r
+ //\r
+ for (Node = FilePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {\r
+ if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) &&\r
+ ((DevicePathSubType (Node) == MSG_USB_CLASS_DP) || (DevicePathSubType (Node) == MSG_USB_WWID_DP))) {\r
+ break;\r
+ }\r
}\r
- }\r
\r
- //\r
- // Expand the USB WWID/Class device path\r
- //\r
- if (!IsDevicePathEnd (Node)) {\r
- if (FilePath == Node) {\r
- //\r
- // Boot Option device path starts with USB Class or USB WWID device path.\r
- // For Boot Option device path which doesn't begin with the USB Class or\r
- // USB WWID device path, it's not needed to connect again here.\r
- //\r
- BmConnectUsbShortFormDevicePath (FilePath);\r
+ //\r
+ // Expand the USB WWID/Class device path\r
+ //\r
+ if (!IsDevicePathEnd (Node)) {\r
+ if (FilePath == Node) {\r
+ //\r
+ // Boot Option device path starts with USB Class or USB WWID device path.\r
+ // For Boot Option device path which doesn't begin with the USB Class or\r
+ // USB WWID device path, it's not needed to connect again here.\r
+ //\r
+ BmConnectUsbShortFormDevicePath (FilePath);\r
+ }\r
+ return BmExpandUsbDevicePath (FilePath, FullPath, Node);\r
}\r
- return BmExpandUsbDevicePath (FilePath, FullPath, Node);\r
}\r
}\r
\r