From e423ee31db92d4e298c137814a4341e1cd05739e Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Fri, 16 Feb 2007 01:46:38 -0800 Subject: [SCSI] scsi_scan.c: handle bad inquiry responses A particular USB device has been reporting short inquiry lengths. The SCSI code cannot operate properly unless we get an inquiry length of 36 or above (because of the way we parse vendor and product), so assume at least 36 bytes are valid even if the device reports fewer. This is wrong, but it's no worse than what we're doing now (using the garbage beyond the last reported valid byte). Signed-off-by: Andrew Morton Signed-off-by: James Bottomley --- drivers/scsi/scsi_scan.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'drivers/scsi/scsi_scan.c') diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index a43b9ec3aef..7757e558d52 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -654,6 +654,19 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, * short INQUIRY), an abort here prevents any further use of the * device, including spin up. * + * On the whole, the best approach seems to be to assume the first + * 36 bytes are valid no matter what the device says. That's + * better than copying < 36 bytes to the inquiry-result buffer + * and displaying garbage for the Vendor, Product, or Revision + * strings. + */ + if (sdev->inquiry_len < 36) { + printk(KERN_INFO "scsi scan: INQUIRY result too short (%d)," + " using 36\n", sdev->inquiry_len); + sdev->inquiry_len = 36; + } + + /* * Related to the above issue: * * XXX Devices (disk or all?) should be sent a TEST UNIT READY, -- cgit v1.2.3 From 7c9d6f16f50d3aeb780e4f103a1ba8b35d9ae803 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Mon, 8 Jan 2007 11:12:32 -0500 Subject: [SCSI] SCSI core: better initialization for sdev->scsi_level This patch will affect the CDB in INQUIRY commands sent to LUNs above 0 when LUN-0 reports a scsi_level of 0; the LUN bits will no longer be set in the second byte of the CDB. This is as it should be. Nevertheless, it's possible that some wacky device might be adversely affected. I doubt anyone will complain... Signed-off-by: Alan Stern Signed-off-by: James Bottomley --- drivers/scsi/scsi_scan.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/scsi/scsi_scan.c') diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 7757e558d52..6905ffd135b 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -385,6 +385,7 @@ static struct scsi_target *scsi_alloc_target(struct device *parent, INIT_LIST_HEAD(&starget->siblings); INIT_LIST_HEAD(&starget->devices); starget->state = STARGET_RUNNING; + starget->scsi_level = SCSI_2; retry: spin_lock_irqsave(shost->host_lock, flags); -- cgit v1.2.3