- Check if the request is for a valid PDO

svn path=/trunk/; revision=55756
This commit is contained in:
Johannes Anderwald 2012-02-20 15:54:19 +00:00
parent 123637fd96
commit 1c6cfe79fb

View file

@ -123,6 +123,33 @@ FowardUrbToRootHub(
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,
@ -154,6 +181,15 @@ USBHUB_PdoHandleInternalDeviceControl(
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)
{
case IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO: