diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c index ca912b4eb0..128eb70139 100644 --- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c @@ -2061,22 +2061,42 @@ ConvertFromTextUsbClass ( PIDStr = GetNextParamStr (&TextDeviceNode); if (UsbClassText->ClassExist) { ClassStr = GetNextParamStr (&TextDeviceNode); - UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr); + if (*ClassStr == L'\0') { + UsbClass->DeviceClass = 0xFF; + } else { + UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr); + } } else { UsbClass->DeviceClass = UsbClassText->Class; } if (UsbClassText->SubClassExist) { SubClassStr = GetNextParamStr (&TextDeviceNode); - UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr); + if (*SubClassStr == L'\0') { + UsbClass->DeviceSubClass = 0xFF; + } else { + UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr); + } } else { UsbClass->DeviceSubClass = UsbClassText->SubClass; } ProtocolStr = GetNextParamStr (&TextDeviceNode); - UsbClass->VendorId = (UINT16) Strtoi (VIDStr); - UsbClass->ProductId = (UINT16) Strtoi (PIDStr); - UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr); + if (*VIDStr == L'\0') { + UsbClass->VendorId = 0xFFFF; + } else { + UsbClass->VendorId = (UINT16) Strtoi (VIDStr); + } + if (*PIDStr == L'\0') { + UsbClass->ProductId = 0xFFFF; + } else { + UsbClass->ProductId = (UINT16) Strtoi (PIDStr); + } + if (*ProtocolStr == L'\0') { + UsbClass->DeviceProtocol = 0xFF; + } else { + UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr); + } return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass; }