*DevicePath = NextDevicePathNode (*DevicePath);\r
}\r
\r
- SetDevicePathEndNode (*DevicePath);\r
+ //\r
+ // Do not call SetDevicePathEndNode() if the device path node is already the\r
+ // end of an entire device path.\r
+ //\r
+ if (!IsDevicePathEnd (*DevicePath)) {\r
+ SetDevicePathEndNode (*DevicePath);\r
+ }\r
}\r
\r
/*\r