Skip to content

Commit 1c6cfe7

Browse files
committed
[USBHUB]
- Check if the request is for a valid PDO svn path=/trunk/; revision=55756
1 parent 123637f commit 1c6cfe7

File tree

1 file changed

+36
-0
lines changed
  • reactos/drivers/usb/usbhub

1 file changed

+36
-0
lines changed

reactos/drivers/usb/usbhub/pdo.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,33 @@ FowardUrbToRootHub(
123123
return STATUS_PENDING;
124124
}
125125

126+
BOOLEAN
127+
IsValidPDO(
128+
IN PDEVICE_OBJECT DeviceObject)
129+
{
130+
ULONG Index;
131+
PHUB_DEVICE_EXTENSION HubDeviceExtension;
132+
PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension;
133+
134+
135+
ChildDeviceExtension = (PHUB_CHILDDEVICE_EXTENSION)DeviceObject->DeviceExtension;
136+
ASSERT(ChildDeviceExtension->Common.IsFDO == FALSE);
137+
HubDeviceExtension = (PHUB_DEVICE_EXTENSION)ChildDeviceExtension->ParentDeviceObject->DeviceExtension;
138+
139+
for(Index = 0; Index < USB_MAXCHILDREN; Index++)
140+
{
141+
if (HubDeviceExtension->ChildDeviceObject[Index] == DeviceObject)
142+
{
143+
/* PDO exists */
144+
return TRUE;
145+
}
146+
}
147+
148+
/* invalid pdo */
149+
return FALSE;
150+
}
151+
152+
126153
NTSTATUS
127154
USBHUB_PdoHandleInternalDeviceControl(
128155
IN PDEVICE_OBJECT DeviceObject,
@@ -154,6 +181,15 @@ USBHUB_PdoHandleInternalDeviceControl(
154181
HubDeviceExtension = (PHUB_DEVICE_EXTENSION)ChildDeviceExtension->ParentDeviceObject->DeviceExtension;
155182
RootHubDeviceObject = HubDeviceExtension->RootHubPhysicalDeviceObject;
156183

184+
if(!IsValidPDO(DeviceObject))
185+
{
186+
DPRINT1("[USBHUB] Request for removed device object %p\n", DeviceObject);
187+
Irp->IoStatus.Status = STATUS_DEVICE_NOT_CONNECTED;
188+
Irp->IoStatus.Information = 0;
189+
IoCompleteRequest(Irp, IO_NO_INCREMENT);
190+
return STATUS_DEVICE_NOT_CONNECTED;
191+
}
192+
157193
switch (Stack->Parameters.DeviceIoControl.IoControlCode)
158194
{
159195
case IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO:

0 commit comments

Comments
 (0)