If control device creation fails - memory
allocated for control device object gets leaked.
The issue is found by HCK fault injection test.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This patch fixes crash on cleanup after unsuccessfull
filter device creation.
Found by HCK fault injection test.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
If driver fails filter device creation process
before WDF device created context memory allocated
must be freed explicitely.
Bug found by HCK fault injection test.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This patch removes CWdfMemoryBuffer class
and merges CMemoryBuffer with CWdmMemoryBuffer
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Return number of bytes transferred without transfer header.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This patch fixes 2 issues from Bugzilla:
1. BZ#1136908 - Windows XP launches "Found New Hardware" dialog
when the device gets redirected after plugging
2. BZ#1101593 - Windows reports unsuccessful driver installation
after USB redirection
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
It is basically forbidden to send arbitrary requests to device
directly via PDO while device driver is present in device stack.
This may lead to unexpected behaviour because device may be
in many different states e.g. low power, processing other
requests etc.
In order to avoid sending descriptor requests to devices with
active functional driver we're caching all descriptors we need
on QDR post-processing while we're on top of device stack for
sure.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
WDF request completion information must always be
sizeof(USBDK_TRANSFER_REQUEST) because this is what
user mode passes to Read/Write syscalls.
The length of transfered data must be always returned via
USB_DK_TRANSFER_RESULT structure.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
The problem revealed while testing with driver verifier.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
In some cases driver sends IOCTLS to the underlying devices.
It uses IoBuildDeviceIoControlRequest() function to allocate
IOCTL IRP.
This function allocates threaded IRP which has a number of
limitations for contexts it may be sent from.
In particular it must be sent from PASSIVE_LEVEL
and non-arbitrary thread context to complete successfully.
Since this is not always true for contexts driver sends IRPs from,
never completed IOCTLs were observed on load tests.
This patch fixes the problem by using IoAllocateIrp()
function to allocate IOCTL IRPs.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
During stop redirection process driver signals
redirection stopped event before adding corresponding
device back to childen list.
In case of unfortunate timing client code that
enumerates devices right after stoppng redirection
may not get device for which redirection was stopped
in devices list.
This patch fixes the issue by changing order of
corresponding operations.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Move redirection stopped event signalling from DeviceAdd
callback to QDR post-processing callback.
DeviceAdd callback is not (usually) called for non-redirected devices.
Without this patch stop redirection process fails to
complete because corresponing event never set.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This is a refactoring commit to make code more simple.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Some transfers may be pended for a long time, especially
on input pipes. In order to avoid deadlocks cancel pending
transfers instead of waiting for completion.
Replace WdfIoQueueStopSynchronously() by WdfIoQueueDrain()
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>