tree 3a440b2a471ef4ab57b8aa75c3b068b2b52910ed
parent d18d36b4edbb980c9de7fe00724c3ded5de1b7a7
author Jeff Garzik <[EMAIL PROTECTED]> Sat, 27 Aug 2005 12:20:12 -0400
committer Jeff Garzik <[EMAIL PROTECTED]> Sat, 27 Aug 2005 12:20:12 -0400

[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.

 drivers/scsi/libata-scsi.c |   10 ++++++++++
 1 files changed, 10 insertions(+)

diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -630,11 +630,19 @@ static unsigned int ata_scsi_rw_xlat(str
                tf->lbah = scsicmd[3];
 
                VPRINTK("ten-byte command\n");
+               if (qc->nsect == 0) /* we don't support length==0 cmds */
+                       return 1;
                return 0;
        }
 
        if (scsicmd[0] == READ_6 || scsicmd[0] == WRITE_6) {
                qc->nsect = tf->nsect = scsicmd[4];
+               if (!qc->nsect) {
+                       qc->nsect = 256;
+                       if (lba48)
+                               tf->hob_nsect = 1;
+               }
+
                tf->lbal = scsicmd[3];
                tf->lbam = scsicmd[2];
                tf->lbah = scsicmd[1] & 0x1f; /* mask out reserved bits */
@@ -674,6 +682,8 @@ static unsigned int ata_scsi_rw_xlat(str
                tf->lbah = scsicmd[7];
 
                VPRINTK("sixteen-byte command\n");
+               if (qc->nsect == 0) /* we don't support length==0 cmds */
+                       return 1;
                return 0;
        }
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to