aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2012-04-11 16:09:10 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-07 11:56:36 -0400
commit06200304e7eb237015f433bd8884975e93aba1f5 (patch)
tree959318315374c7637e9e72788e5d5cc699198a6b
parenta8eaeff79eb97662e2d06cc1919d902fc251e9da (diff)
USB: gadget: storage gadgets send wrong error code for unknown commands
commit c85dcdac5852295cf6822f5c4331a6ddab72581f upstream. This patch (as1539) fixes a minor bug in the mass-storage gadget drivers. When an unknown command is received, the error code sent back is "Invalid Field in CDB" rather than "Invalid Command". This is because the bitmask of CDB bytes allowed to be nonzero is incorrect. When handling an unknown command, we don't care which command bytes are nonzero. All the bits in the mask should be set, not just eight of them. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> CC: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/gadget/f_mass_storage.c2
-rw-r--r--drivers/usb/gadget/file_storage.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index efb58f9f5aa..3bbdc9aa1de 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -2187,7 +2187,7 @@ unknown_cmnd:
2187 common->data_size_from_cmnd = 0; 2187 common->data_size_from_cmnd = 0;
2188 sprintf(unknown, "Unknown x%02x", common->cmnd[0]); 2188 sprintf(unknown, "Unknown x%02x", common->cmnd[0]);
2189 reply = check_command(common, common->cmnd_size, 2189 reply = check_command(common, common->cmnd_size,
2190 DATA_DIR_UNKNOWN, 0xff, 0, unknown); 2190 DATA_DIR_UNKNOWN, ~0, 0, unknown);
2191 if (reply == 0) { 2191 if (reply == 0) {
2192 common->curlun->sense_data = SS_INVALID_COMMAND; 2192 common->curlun->sense_data = SS_INVALID_COMMAND;
2193 reply = -EINVAL; 2193 reply = -EINVAL;
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 0360f56221e..e358130a485 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -2553,7 +2553,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2553 fsg->data_size_from_cmnd = 0; 2553 fsg->data_size_from_cmnd = 0;
2554 sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]); 2554 sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]);
2555 if ((reply = check_command(fsg, fsg->cmnd_size, 2555 if ((reply = check_command(fsg, fsg->cmnd_size,
2556 DATA_DIR_UNKNOWN, 0xff, 0, unknown)) == 0) { 2556 DATA_DIR_UNKNOWN, ~0, 0, unknown)) == 0) {
2557 fsg->curlun->sense_data = SS_INVALID_COMMAND; 2557 fsg->curlun->sense_data = SS_INVALID_COMMAND;
2558 reply = -EINVAL; 2558 reply = -EINVAL;
2559 } 2559 }