Skip to contentSkip to conversation

stex: fix scan of nonexistent lun

PATCH New Ed Lin 1 participant 1 message Dec 19, 2009 SCSI

lore
Share & tools
lore

Ed Lin

author
#0 lore raw

PATCH 1/1 stex: fix scan of nonexistent lun

During a manual scan, a user can send command to a nonexistent lun, precisely at the point of max_lun. Normally it's possible (but not required) that the firmware has the knowledge that it is an invalid lun. In the particular case when max_lun is 256, however, the nonexistent lun 256 will be confused with lun 0, because the lun member in a request message is only u8, and 256 will become 0. So we need to fix the problem, at least, at the driver level.

---

drivers/scsi/stex.c +5 -0
index 3058bb1..fd7b15b 100644
@@ -623,6 +623,11 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
 		}
 		break;
 	case INQUIRY:
+		if (lun >= host->max_lun) {
+			cmd->result = DID_NO_CONNECT << 16;
+			done(cmd);
+			return 0;
+		}
 		if (id != host->max_id - 1)
 			break;
 		if (!lun && !cmd->device->channel &&