aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage
diff options
context:
space:
mode:
authorMark Knibbs <markk@clara.co.uk>2014-11-04 08:00:22 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-07 11:56:05 -0500
commit55dc68c012bf056880c03d9f6eb34c00880f9e88 (patch)
treeace609d80dec37ace0dab0a8ae71803e16815f6b /drivers/usb/storage
parentd9c3ae28bd6b72803e266eb384e0ba312f9ff837 (diff)
USB: storage: Reject bogus max LUN values
Some mass storage devices return a bogus value in response to a Get Max LUN request. The Iomega Jaz USB Adapter responds with 0x10, hence my recent patch to use the US_FL_SINGLE_LUN quirk for it. The USB MSC Bulk Only Transport document says "The device shall return one byte of data that contains the maximum LUN supported by the device." Since the LUN field in the command block wrapper is only 4 bits wide, it might be helpful to report too-large LUN values in the kernel log, and assume max LUN is actually 0. That could get some devices which currently need the US_FL_SINGLE_LUN quirk to work. Signed-off-by: Mark Knibbs <markk@clara.co.uk> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/storage')
-rw-r--r--drivers/usb/storage/transport.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 22c7d4360fa2..d614deeacd87 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -1035,9 +1035,20 @@ int usb_stor_Bulk_max_lun(struct us_data *us)
1035 usb_stor_dbg(us, "GetMaxLUN command result is %d, data is %d\n", 1035 usb_stor_dbg(us, "GetMaxLUN command result is %d, data is %d\n",
1036 result, us->iobuf[0]); 1036 result, us->iobuf[0]);
1037 1037
1038 /* if we have a successful request, return the result */ 1038 /*
1039 if (result > 0) 1039 * If we have a successful request, return the result if valid. The
1040 return us->iobuf[0]; 1040 * CBW LUN field is 4 bits wide, so the value reported by the device
1041 * should fit into that.
1042 */
1043 if (result > 0) {
1044 if (us->iobuf[0] < 16) {
1045 return us->iobuf[0];
1046 } else {
1047 dev_info(&us->pusb_intf->dev,
1048 "Max LUN %d is not valid, using 0 instead",
1049 us->iobuf[0]);
1050 }
1051 }
1041 1052
1042 /* 1053 /*
1043 * Some devices don't like GetMaxLUN. They may STALL the control 1054 * Some devices don't like GetMaxLUN. They may STALL the control