Skip to content

Commit 4d173b1

Browse files
committed
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. svn path=/branches/GSoC_2016/USB/; revision=72379
1 parent c48f1cf commit 4d173b1

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

drivers/usb/usbhub/fdo.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,10 +1232,6 @@ CreateUsbChildDeviceObject(
12321232
UsbChildExtension->ParentDeviceObject = UsbHubDeviceObject;
12331233
UsbChildExtension->PortNumber = PortId;
12341234

1235-
// copy device interface
1236-
RtlCopyMemory(&UsbChildExtension->DeviceInterface, &HubDeviceExtension->DeviceInterface, sizeof(USB_BUS_INTERFACE_USBDI_V2));
1237-
1238-
12391235
//
12401236
// Create the UsbDeviceObject
12411237
//
@@ -1250,12 +1246,6 @@ CreateUsbChildDeviceObject(
12501246
goto Cleanup;
12511247
}
12521248

1253-
// copy device interface
1254-
RtlCopyMemory(&UsbChildExtension->DeviceInterface, &HubDeviceExtension->DeviceInterface, sizeof(USB_BUS_INTERFACE_USBDI_V2));
1255-
1256-
// FIXME replace buscontext
1257-
UsbChildExtension->DeviceInterface.BusContext = UsbChildExtension->UsbDeviceHandle;
1258-
12591249
//
12601250
// Initialize UsbDevice
12611251
//
@@ -1345,6 +1335,10 @@ CreateUsbChildDeviceObject(
13451335
goto Cleanup;
13461336
}
13471337

1338+
// copy device interface
1339+
RtlCopyMemory(&UsbChildExtension->DeviceInterface, &HubDeviceExtension->UsbDInterface, sizeof(USB_BUS_INTERFACE_USBDI_V2));
1340+
UsbChildExtension->DeviceInterface.InterfaceReference(UsbChildExtension->DeviceInterface.BusContext);
1341+
13481342
UsbChildExtension->IsRemovePending = FALSE;
13491343

13501344
HubDeviceExtension->ChildDeviceObject[ChildDeviceCount] = NewChildDeviceObject;

0 commit comments

Comments
 (0)