Author: janderwald
Date: Mon Feb 20 15:54:19 2012
New Revision: 55756
URL: 
http://svn.reactos.org/svn/reactos?rev=55756&view=rev
Log:
[USBHUB]
- Check if the request is for a valid PDO
Modified:
    trunk/reactos/drivers/usb/usbhub/pdo.c
Modified: trunk/reactos/drivers/usb/usbhub/pdo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbhub/pdo.c?r…
==============================================================================
--- trunk/reactos/drivers/usb/usbhub/pdo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbhub/pdo.c [iso-8859-1] Mon Feb 20 15:54:19 2012
@@ -123,6 +123,33 @@
     return STATUS_PENDING;
 }
+BOOLEAN
+IsValidPDO(
+    IN PDEVICE_OBJECT DeviceObject)
+{
+    ULONG Index;
+    PHUB_DEVICE_EXTENSION HubDeviceExtension;
+    PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension;
+
+
+    ChildDeviceExtension = (PHUB_CHILDDEVICE_EXTENSION)DeviceObject->DeviceExtension;
+    ASSERT(ChildDeviceExtension->Common.IsFDO == FALSE);
+    HubDeviceExtension =
(PHUB_DEVICE_EXTENSION)ChildDeviceExtension->ParentDeviceObject->DeviceExtension;
+
+    for(Index = 0; Index < USB_MAXCHILDREN; Index++)
+    {
+        if (HubDeviceExtension->ChildDeviceObject[Index] == DeviceObject)
+        {
+            /* PDO exists */
+            return TRUE;
+        }
+    }
+
+    /* invalid pdo */
+    return FALSE;
+}
+
+
 NTSTATUS
 USBHUB_PdoHandleInternalDeviceControl(
     IN PDEVICE_OBJECT DeviceObject,
@@ -153,6 +180,15 @@
     ASSERT(ChildDeviceExtension->Common.IsFDO == FALSE);
     HubDeviceExtension =
(PHUB_DEVICE_EXTENSION)ChildDeviceExtension->ParentDeviceObject->DeviceExtension;
     RootHubDeviceObject = HubDeviceExtension->RootHubPhysicalDeviceObject;
+
+    if(!IsValidPDO(DeviceObject))
+    {
+        DPRINT1("[USBHUB] Request for removed device object %p\n",
DeviceObject);
+        Irp->IoStatus.Status = STATUS_DEVICE_NOT_CONNECTED;
+        Irp->IoStatus.Information = 0;
+        IoCompleteRequest(Irp, IO_NO_INCREMENT);
+        return STATUS_DEVICE_NOT_CONNECTED;
+    }
     switch (Stack->Parameters.DeviceIoControl.IoControlCode)
     {