[USBPORT] Specify the correct length for the root hub's hub descriptor.
authorThomas Faber <thomas.faber@reactos.org>
Thu, 16 Aug 2018 12:10:15 +0000 (14:10 +0200)
committerThomas Faber <thomas.faber@reactos.org>
Thu, 16 Aug 2018 12:14:31 +0000 (14:14 +0200)
drivers/usb/usbport/roothub.c

index 984569f..5808b42 100644 (file)
@@ -786,7 +786,7 @@ USBPORT_RootHubCreateDevice(IN PDEVICE_OBJECT FdoDevice,
     Packet->RH_GetRootHubData(FdoExtension->MiniPortExt, &RootHubData);
 
     ASSERT(RootHubData.NumberOfPorts != 0);
-    NumMaskByte = ((RootHubData.NumberOfPorts - 1) >> 3) + 1;
+    NumMaskByte = (RootHubData.NumberOfPorts - 1) / 8 + 1;
 
     DescriptorsLength = sizeof(USB_DEVICE_DESCRIPTOR) +
                         sizeof(USB_CONFIGURATION_DESCRIPTOR) +
@@ -859,7 +859,7 @@ USBPORT_RootHubCreateDevice(IN PDEVICE_OBJECT FdoDevice,
 
         RH_HubDescriptor = &PdoExtension->RootHubDescriptors->Descriptor;
 
-        RH_HubDescriptor->bDescriptorLength = sizeof(USB_HUB_DESCRIPTOR) + 2 * NumMaskByte;
+        RH_HubDescriptor->bDescriptorLength = FIELD_OFFSET(USB_HUB_DESCRIPTOR, bRemoveAndPowerMask) + 2 * NumMaskByte;
 
         if (Packet->MiniPortVersion == USB_MINIPORT_VERSION_OHCI ||
             Packet->MiniPortVersion == USB_MINIPORT_VERSION_UHCI ||