From 8d412afe306673a3fad0c21109051b9a59d63821 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Fri, 19 Sep 2008 02:00:02 +0300 Subject: [PATCH] --- yaml --- r: 115763 b: refs/heads/master c: 549c41e0ac0a3eb68cfdaeb43c1a314e2a6c289a h: refs/heads/master i: 115761: 038f816567cdec94ec19eabbc5a9063bd095884c 115759: 41fe423138b267b7843a0ce681cfb4597f1485e3 v: v3 --- [refs] | 2 +- trunk/drivers/usb/gadget/file_storage.c | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index a2d0a7d353b7..709d84f313ee 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 8296345a35551414b07419f4c9223734c1fc5437 +refs/heads/master: 549c41e0ac0a3eb68cfdaeb43c1a314e2a6c289a diff --git a/trunk/drivers/usb/gadget/file_storage.c b/trunk/drivers/usb/gadget/file_storage.c index 0c632d22a631..e0f616f39ba0 100644 --- a/trunk/drivers/usb/gadget/file_storage.c +++ b/trunk/drivers/usb/gadget/file_storage.c @@ -2676,11 +2676,24 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size, /* Verify the length of the command itself */ if (cmnd_size != fsg->cmnd_size) { - /* Special case workaround: MS-Windows issues REQUEST SENSE - * with cbw->Length == 12 (it should be 6). */ - if (fsg->cmnd[0] == SC_REQUEST_SENSE && fsg->cmnd_size == 12) + /* Special case workaround: There are plenty of buggy SCSI + * implementations. Many have issues with cbw->Length + * field passing a wrong command size. For those cases we + * always try to work around the problem by using the length + * sent by the host side provided it is at least as large + * as the correct command length. + * Examples of such cases would be MS-Windows, which issues + * REQUEST SENSE with cbw->Length == 12 where it should + * be 6, and xbox360 issuing INQUIRY, TEST UNIT READY and + * REQUEST SENSE with cbw->Length == 10 where it should + * be 6 as well. + */ + if (cmnd_size <= fsg->cmnd_size) { + DBG(fsg, "%s is buggy! Expected length %d " + "but we got %d\n", name, + cmnd_size, fsg->cmnd_size); cmnd_size = fsg->cmnd_size; - else { + } else { fsg->phase_error = 1; return -EINVAL; }