提交 13593265 编写于 作者: J Jeff Garzik

[libata scsi] fix read/write translation edge cases

Fix bugs for unlikely edge cases noticed by Douglas Gilbert:

- When READ(6)/WRITE(6) sector count == 0, treat it as 256 sectors

- For other READ(x)/WRITE(x), when sector count == 0, error.
  We don't support successfully completing zero-length transfers at
  this time.
上级 d18d36b4
...@@ -630,11 +630,19 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) ...@@ -630,11 +630,19 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd)
tf->lbah = scsicmd[3]; tf->lbah = scsicmd[3];
VPRINTK("ten-byte command\n"); VPRINTK("ten-byte command\n");
if (qc->nsect == 0) /* we don't support length==0 cmds */
return 1;
return 0; return 0;
} }
if (scsicmd[0] == READ_6 || scsicmd[0] == WRITE_6) { if (scsicmd[0] == READ_6 || scsicmd[0] == WRITE_6) {
qc->nsect = tf->nsect = scsicmd[4]; qc->nsect = tf->nsect = scsicmd[4];
if (!qc->nsect) {
qc->nsect = 256;
if (lba48)
tf->hob_nsect = 1;
}
tf->lbal = scsicmd[3]; tf->lbal = scsicmd[3];
tf->lbam = scsicmd[2]; tf->lbam = scsicmd[2];
tf->lbah = scsicmd[1] & 0x1f; /* mask out reserved bits */ tf->lbah = scsicmd[1] & 0x1f; /* mask out reserved bits */
...@@ -674,6 +682,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) ...@@ -674,6 +682,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd)
tf->lbah = scsicmd[7]; tf->lbah = scsicmd[7];
VPRINTK("sixteen-byte command\n"); VPRINTK("sixteen-byte command\n");
if (qc->nsect == 0) /* we don't support length==0 cmds */
return 1;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册