Author: vmikayelyan
Date: Fri Aug 19 16:22:18 2016
New Revision: 72379
URL:
http://svn.reactos.org/svn/reactos?rev=72379&view=rev
Log:
usb: hub: FDO: Fix CreateUsbChildDeviceObject()
There were code dublication on copy device interface, also after
copying interface, we should call InterfaceReference() routine of
interface, to prevent interface provider deleiton.
I have moved RtlCopyMemory() and InterfaceReference() to the end
of this function to siplify cleanup part, because otherwise we should
call InterfaceDereference() in cleanup part.
The changing of interface context seems wrong for me, let me give just
one example. When we are changing only buscontext, then when upper
layer calls interfaceDereference(), which is "thinking" that works with
it's buscontext, and tries to work with it using it's buscontext
pointer. So changing of buscontext is completely wrong.
Modified:
branches/GSoC_2016/USB/drivers/usb/usbhub/fdo.c
Modified: branches/GSoC_2016/USB/drivers/usb/usbhub/fdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/USB/drivers/usb/usbhu…
==============================================================================
--- branches/GSoC_2016/USB/drivers/usb/usbhub/fdo.c [iso-8859-1] (original)
+++ branches/GSoC_2016/USB/drivers/usb/usbhub/fdo.c [iso-8859-1] Fri Aug 19 16:22:18 2016
@@ -1232,10 +1232,6 @@
UsbChildExtension->ParentDeviceObject = UsbHubDeviceObject;
UsbChildExtension->PortNumber = PortId;
- // copy device interface
- RtlCopyMemory(&UsbChildExtension->DeviceInterface,
&HubDeviceExtension->DeviceInterface, sizeof(USB_BUS_INTERFACE_USBDI_V2));
-
-
//
// Create the UsbDeviceObject
//
@@ -1249,12 +1245,6 @@
DPRINT1("USBHUB: CreateUsbDevice failed with status %x\n", Status);
goto Cleanup;
}
-
- // copy device interface
- RtlCopyMemory(&UsbChildExtension->DeviceInterface,
&HubDeviceExtension->DeviceInterface, sizeof(USB_BUS_INTERFACE_USBDI_V2));
-
- // FIXME replace buscontext
- UsbChildExtension->DeviceInterface.BusContext =
UsbChildExtension->UsbDeviceHandle;
//
// Initialize UsbDevice
@@ -1344,6 +1334,10 @@
DPRINT1("Failed to create strings needed to describe device to
PNP.\n");
goto Cleanup;
}
+
+ // copy device interface
+ RtlCopyMemory(&UsbChildExtension->DeviceInterface,
&HubDeviceExtension->UsbDInterface, sizeof(USB_BUS_INTERFACE_USBDI_V2));
+
UsbChildExtension->DeviceInterface.InterfaceReference(UsbChildExtension->DeviceInterface.BusContext);
UsbChildExtension->IsRemovePending = FALSE;