提交 c85dcdac 编写于 作者: A Alan Stern 提交者: Felipe Balbi

USB: gadget: storage gadgets send wrong error code for unknown commands

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: NAlan Stern <stern@rowland.harvard.edu>
CC: <Michal Nazarewicz <mina86@mina86.com>
CC: <stable@vger.kernel.org>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 662c738d
...@@ -2189,7 +2189,7 @@ static int do_scsi_command(struct fsg_common *common) ...@@ -2189,7 +2189,7 @@ static int do_scsi_command(struct fsg_common *common)
common->data_size_from_cmnd = 0; common->data_size_from_cmnd = 0;
sprintf(unknown, "Unknown x%02x", common->cmnd[0]); sprintf(unknown, "Unknown x%02x", common->cmnd[0]);
reply = check_command(common, common->cmnd_size, reply = check_command(common, common->cmnd_size,
DATA_DIR_UNKNOWN, 0xff, 0, unknown); DATA_DIR_UNKNOWN, ~0, 0, unknown);
if (reply == 0) { if (reply == 0) {
common->curlun->sense_data = SS_INVALID_COMMAND; common->curlun->sense_data = SS_INVALID_COMMAND;
reply = -EINVAL; reply = -EINVAL;
......
...@@ -2579,7 +2579,7 @@ static int do_scsi_command(struct fsg_dev *fsg) ...@@ -2579,7 +2579,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
fsg->data_size_from_cmnd = 0; fsg->data_size_from_cmnd = 0;
sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]); sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]);
if ((reply = check_command(fsg, fsg->cmnd_size, if ((reply = check_command(fsg, fsg->cmnd_size,
DATA_DIR_UNKNOWN, 0xff, 0, unknown)) == 0) { DATA_DIR_UNKNOWN, ~0, 0, unknown)) == 0) {
fsg->curlun->sense_data = SS_INVALID_COMMAND; fsg->curlun->sense_data = SS_INVALID_COMMAND;
reply = -EINVAL; reply = -EINVAL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册