Skip to content

Commit 0f9441b

Browse files
committed
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. svn path=/branches/GSoC_2016/USB/; revision=72383
1 parent a0b1bf2 commit 0f9441b

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

drivers/usb/usbhub/pdo.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,16 @@ USBHUB_PdoHandlePnp(
745745
}
746746
case IRP_MN_QUERY_REMOVE_DEVICE:
747747
{
748-
// HERE SHOULD BE CHECKED INTERFACE COUNT PROVIED TO UPPER LAYER TO BE ZERO, AS WE ARE HANDLING
749-
// IRP_MN_QUERY_INTERFACE IN WRONG WAY, THAT WILL BE DONE LATER. SEE MSDN "IRP_MN_QUERY_INTERFACE"
748+
//
749+
// Free interface obtained from bottom, according MSDN we should
750+
// check interfaces provided to top, but here we are not checking.
751+
// All checking will be performed in roothub driver's
752+
// IRP_MN_QUERY_REMOVE_DEVICE handler. This will make problems when
753+
// buggy driver is loaded on top of us. But we decided to keep source
754+
// simpler, because in any case buggy driver will prevent removing of
755+
// whole stack.
756+
//
757+
UsbChildExtension->DeviceInterface.InterfaceDereference(UsbChildExtension->DeviceInterface.BusContext);
750758

751759
UsbChildExtension->IsRemovePending = TRUE;
752760

@@ -755,6 +763,18 @@ USBHUB_PdoHandlePnp(
755763
Information = 0;
756764
break;
757765
}
766+
case IRP_MN_CANCEL_REMOVE_DEVICE:
767+
{
768+
// Check to see have we received query-remove before
769+
if (UsbChildExtension->IsRemovePending == TRUE)
770+
{
771+
UsbChildExtension->IsRemovePending = FALSE;
772+
UsbChildExtension->DeviceInterface.InterfaceReference(UsbChildExtension->DeviceInterface.BusContext);
773+
}
774+
775+
Status = STATUS_SUCCESS;
776+
break;
777+
}
758778
case IRP_MN_QUERY_INTERFACE:
759779
{
760780
DPRINT1("IRP_MN_QUERY_INTERFACE\n");

0 commit comments

Comments
 (0)