MdeModulePkg/UsbBusDxe: Add UsbControlTransfer() error check
authorMichael D Kinney <michael.d.kinney@intel.com>
Tue, 14 Nov 2017 23:41:08 +0000 (15:41 -0800)
committerMichael D Kinney <michael.d.kinney@intel.com>
Mon, 20 Nov 2017 22:43:28 +0000 (14:43 -0800)
commitb4e96b82b4e2e47e95014b51787ba5b43abac784
tree62f8acf40a98193afec1a7c01fab66b500dca750
parentb8c6c545385da1fec9f0851e2d4f1b769ff121af
MdeModulePkg/UsbBusDxe: Add UsbControlTransfer() error check

https://bugzilla.tianocore.org/show_bug.cgi?id=767

The USB I/O Protocol function ControlTransfer() has a DataLength
parameter that specifies the size of the Data buffer.  The
UsbBusDxe module implements the USB I/O Protocol using the
services of the USB2 Host Controller Protocol.  The DataLength
parameter in the USB2 Host Controller Protocol ControlTransfer()
service is an IN OUT parameter so the number of bytes actually
transferred is returned.  Since the USB I/O Protocol
ControlTransfer() service can not return the number of bytes
actually transferred, the only option if the number of bytes
actually transferred is less than the number of bytes requested
is to return EFI_DEVICE_ERROR.

The change fixes an issue with a USB mass storage device that
responds with 0 bytes to the Get MAX LUN command.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c