summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c')
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
index c1908cf14a..191312bbb3 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
@@ -42,7 +42,12 @@ UsbFreeInterfaceDesc (
}
}
- FreePool (Setting->Endpoints);
+ //
+ // Only call FreePool() if NumEndpoints > 0.
+ //
+ if (Setting->Desc.NumEndpoints > 0) {
+ FreePool (Setting->Endpoints);
+ }
}
FreePool (Setting);
@@ -192,10 +197,13 @@ UsbCreateDesc (
return NULL;
}
- Desc = AllocateCopyPool(CtrlLen, Head);
+ Desc = AllocateZeroPool (CtrlLen);
if (Desc == NULL) {
return NULL;
}
+
+ CopyMem (Desc, Head, DescLen);
+
*Consumed = Offset + Head->Len;
return Desc;
@@ -344,7 +352,11 @@ UsbParseConfigDesc (
DescBuf += Consumed;
Len -= Consumed;
- while (Len > 0) {
+ //
+ // Make allowances for devices that return extra data at the
+ // end of their config descriptors
+ //
+ while (Len >= sizeof (EFI_USB_INTERFACE_DESCRIPTOR)) {
Setting = UsbParseInterfaceDesc (DescBuf, Len, &Consumed);
if ((Setting == NULL)) {