Skip to content

Commit 9a40525

Browse files
htejunjgarzik
authored andcommitted
[PATCH] 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. Signed-off-by: Tejun Heo <[email protected]> Signed-off-by: Jeff Garzik <[email protected]>
1 parent 3b6efee commit 9a40525

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/scsi/libata-scsi.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,7 +2239,7 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
22392239
struct scsi_cmnd *cmd = qc->scsicmd;
22402240

22412241
if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN)
2242-
return 1;
2242+
goto invalid_fld;
22432243

22442244
/*
22452245
* 12 and 16 byte CDBs use different offsets to
@@ -2301,7 +2301,7 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
23012301
*/
23022302
if ((tf->command == ATA_CMD_SET_FEATURES)
23032303
&& (tf->feature == SETFEATURES_XFER))
2304-
return 1;
2304+
goto invalid_fld;
23052305

23062306
/*
23072307
* Set flags so that all registers will be written,
@@ -2322,6 +2322,11 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
23222322
qc->nsect = cmd->bufflen / ATA_SECT_SIZE;
23232323

23242324
return 0;
2325+
2326+
invalid_fld:
2327+
ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x00);
2328+
/* "Invalid field in cdb" */
2329+
return 1;
23252330
}
23262331

23272332
/**

0 commit comments

Comments
 (0)