Skip to contentSkip to conversation

in ata_scsi_pass_thru()

QUESTION Applied Tejun Heo 2 participants 4 messages Nov 30, 2005 – Dec 4, 2005

Subsystems (2)
lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

Hi, all.

In the translation function ata_scsi_pass_thru(), when it determines that the command cannot be translated and should be finished early, it does NOT set sense data or result code. This seems buggy. Is this intentional?

Thanks.

Signature · 1 line
tejun
#1 lore raw
Quoted 3 lines · Tejun Heo

Hi, all.

In the translation function ata_scsi_pass_thru(), when it determines that the command cannot be translated and should be finished early, it does NOT set sense data or result code. This seems buggy. Is this intentional?

Yes, a bug.

Jeff

author
#2 lore raw

PATCH 1/1 libata: fix ata_scsi_pass_thru error handling

This patch makes ata_scsi_pass_thru() properly set result code and sense data on translation failures.

drivers/scsi/libata-scsi.c +7 -2
index 957a9ca..7445d8b 100644
@@ -2233,7 +2233,7 @@ ata_scsi_pass_thru(struct ata_queued_cmd
 	struct scsi_cmnd *cmd = qc->scsicmd;
 
 	if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN)
-		return 1;
+		goto invalid_fld;
 
 	/*
 	 * 12 and 16 byte CDBs use different offsets to
@@ -2295,7 +2295,7 @@ ata_scsi_pass_thru(struct ata_queued_cmd
 	 */
 	if ((tf->command == ATA_CMD_SET_FEATURES)
 	 && (tf->feature == SETFEATURES_XFER))
-		return 1;
+		goto invalid_fld;
 
 	/*
 	 * Set flags so that all registers will be written,
@@ -2316,6 +2316,11 @@ ata_scsi_pass_thru(struct ata_queued_cmd
 	qc->nsect = cmd->bufflen / ATA_SECT_SIZE;
 
 	return 0;
+
+ invalid_fld:
+	ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x00);
+	/* "Invalid field in cdb" */
+	return 1;
 }
 
 /**
Applied
#3 lore raw

Re: [PATCH] libata: fix ata_scsi_pass_thru error handling

applied