Skip to content

Commit

Permalink
FilterDevice: Fix recognition of HUB devices
Browse files Browse the repository at this point in the history
Sometimes UsbDk cannot query device descriptors for USB hubs,
in such cases it does not attach to theirs stack during parent bus
relations processing.

However, since UsbDk is registered as USB hub class filter,
WDF will call its AddDevice callback anyway.

In this case UsbDk should assume that it is dealing with a hub
and assign its usual hub strategy.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
  • Loading branch information
Dmitry Fleytman committed Feb 2, 2017
1 parent bb931ea commit db95b46
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions UsbDk/FilterDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,18 @@ bool CUsbDkFilterDevice::CStrategist::SelectStrategy(PDEVICE_OBJECT DevObj)
USB_DEVICE_DESCRIPTOR DevDescr;
if (!m_Strategy->GetControlDevice()->GetDeviceDescriptor(ID, DevDescr))
{
TraceEvents(TRACE_LEVEL_ERROR, TRACE_FILTERDEVICE, "%!FUNC! Cannot query cached device descriptor");
return false;
// If there is no cached device descriptor then we did not
// attach to this device stack during parent bus enumeration
// (see CUsbDkHubFilterStrategy::RegisterNewChild).
// In this case, the fact that WDF called our
// EVT_WDF_DRIVER_DEVICE_ADD callback for this device means that
// we are dealing with USB hub and WDF attached us to its stack
// automatically because UsbDk is registered in PNP manager as
// USB hubs filter
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC! No cached device descriptor, assigning hub strategy");
m_Strategy->Delete();
m_Strategy = &m_HubStrategy;
return true;
}

// Device class is HUB -> Hub strategy
Expand Down

0 comments on commit db95b46

Please sign in to comment.