Author: vmikayelyan
Date: Fri Aug 19 16:30:53 2016
New Revision: 72383
URL: http://svn.reactos.org/svn/reactos?rev=72383&view=rev
Log:
usb: hub: PDO: Added query-remove and query-cancel-remove handlers
On IRP_MN_QUERY_REMOVE_DEVICE we are freeing interface obtained from
bottom according MSDN we should check interfaces provided to top, but
here we are not checking. All checking will be performed in roothub
driver's IRP_MN_QUERY_REMOVE_DEVICE handler. This will make problems
when buggy driver is loaded on top of us. But we decided to keep source
simpler, because in any case buggy driver will prevent removing of
whole stack.
Modified:
branches/GSoC_2016/USB/drivers/usb/usbhub/pdo.c
Modified: branches/GSoC_2016/USB/drivers/usb/usbhub/pdo.c
URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2016/USB/drivers/usb/usbhu…
==============================================================================
--- branches/GSoC_2016/USB/drivers/usb/usbhub/pdo.c [iso-8859-1] (original)
+++ branches/GSoC_2016/USB/drivers/usb/usbhub/pdo.c [iso-8859-1] Fri Aug 19 16:30:53 2016
@@ -745,14 +745,34 @@
}
case IRP_MN_QUERY_REMOVE_DEVICE:
{
- // HERE SHOULD BE CHECKED INTERFACE COUNT PROVIED TO UPPER LAYER TO BE ZERO, AS WE ARE HANDLING
- // IRP_MN_QUERY_INTERFACE IN WRONG WAY, THAT WILL BE DONE LATER. SEE MSDN "IRP_MN_QUERY_INTERFACE"
+ //
+ // Free interface obtained from bottom, according MSDN we should
+ // check interfaces provided to top, but here we are not checking.
+ // All checking will be performed in roothub driver's
+ // IRP_MN_QUERY_REMOVE_DEVICE handler. This will make problems when
+ // buggy driver is loaded on top of us. But we decided to keep source
+ // simpler, because in any case buggy driver will prevent removing of
+ // whole stack.
+ //
+ UsbChildExtension->DeviceInterface.InterfaceDereference(UsbChildExtension->DeviceInterface.BusContext);
UsbChildExtension->IsRemovePending = TRUE;
/* Sure, no problem */
Status = STATUS_SUCCESS;
Information = 0;
+ break;
+ }
+ case IRP_MN_CANCEL_REMOVE_DEVICE:
+ {
+ // Check to see have we received query-remove before
+ if (UsbChildExtension->IsRemovePending == TRUE)
+ {
+ UsbChildExtension->IsRemovePending = FALSE;
+ UsbChildExtension->DeviceInterface.InterfaceReference(UsbChildExtension->DeviceInterface.BusContext);
+ }
+
+ Status = STATUS_SUCCESS;
break;
}
case IRP_MN_QUERY_INTERFACE:
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;