Skip to content

Commit 9ec7704

Browse files
committed
[USBSTOR] Fix USBSTOR_SendCSWRequest().
1 parent 07a2935 commit 9ec7704

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

drivers/usb/usbstor/scsi.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,30 @@ USBSTOR_CSWCompletionRoutine(
240240

241241
NTSTATUS
242242
USBSTOR_SendCSWRequest(
243-
PFDO_DEVICE_EXTENSION FDODeviceExtension,
244-
PIRP Irp)
243+
_In_ PFDO_DEVICE_EXTENSION FDODeviceExtension,
244+
_In_ PIRP Irp)
245245
{
246+
ULONG TransferBufferLength;
247+
ULONG TransferFlags;
248+
249+
DPRINT("USBSTOR_SendCSWRequest: %p, %p\n", FDODeviceExtension, Irp);
250+
251+
if (FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkInPipeIndex].MaximumPacketSize == 0x200)
252+
{
253+
TransferBufferLength = 0x200;
254+
TransferFlags = USBD_SHORT_TRANSFER_OK;
255+
}
256+
else
257+
{
258+
TransferBufferLength = sizeof(CSW);
259+
TransferFlags = 0;
260+
}
261+
246262
return USBSTOR_IssueBulkOrInterruptRequest(FDODeviceExtension,
247263
Irp,
248264
FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkInPipeIndex].PipeHandle,
249-
USBD_TRANSFER_DIRECTION_IN,
250-
sizeof(CSW),
265+
TransferFlags,
266+
TransferBufferLength,
251267
&FDODeviceExtension->CurrentIrpContext.csw,
252268
NULL,
253269
USBSTOR_CSWCompletionRoutine);

drivers/usb/usbstor/usbstor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ USBSTOR_HandleExecuteSCSI(
345345

346346
NTSTATUS
347347
USBSTOR_SendCSWRequest(
348-
PFDO_DEVICE_EXTENSION FDODeviceExtension,
349-
PIRP Irp);
348+
_In_ PFDO_DEVICE_EXTENSION FDODeviceExtension,
349+
_In_ PIRP Irp);
350350

351351
NTSTATUS
352352
NTAPI

0 commit comments

Comments
 (0)