Patchwork [5/5] scsi: Ensure command and transfer lengths are set for all SCSI stream commands.

login
register
mail settings
Submitter Christian Borntraeger
Date June 14, 2012, 1:55 p.m.
Message ID <1339682129-1497-6-git-send-email-borntraeger@de.ibm.com>
Download mbox | patch
Permalink /patch/164938/
State New
Headers show

Comments

Christian Borntraeger - June 14, 2012, 1:55 p.m.
From: Christian Hoff <christian.hoff@de.ibm.com>

scsi-generic relies on those values to be correct, so it is important that
those values are initialized properly prior to submitting the SCSI command.

Signed-off-by: Christian Hoff <christian.hoff@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 hw/scsi-bus.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 9854321..3c3f190 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -817,7 +817,11 @@  static int scsi_req_stream_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *bu
     switch (buf[0]) {
     /* stream commands */
     case ERASE_12:
+        cmd->len = 12;
+        cmd->xfer = 0;
+        break;
     case ERASE_16:
+        cmd->len = 16;
         cmd->xfer = 0;
         break;
     case READ_6:
@@ -836,9 +840,12 @@  static int scsi_req_stream_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *bu
         cmd->xfer = 0;
         break;
     case SPACE_16:
+        cmd->len = 16;
         cmd->xfer = buf[13] | (buf[12] << 8);
         break;
     case READ_POSITION:
+        cmd->len = 10;
+
         switch (buf[1] & 0x1f) /* operation code */ {
         case SHORT_FORM_BLOCK_ID:
         case SHORT_FORM_VENDOR_SPECIFIC:
@@ -856,6 +863,7 @@  static int scsi_req_stream_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *bu
 
         break;
     case FORMAT_UNIT:
+        cmd->len = 6;
         cmd->xfer = buf[4] | (buf[3] << 8);
         break;
     /* generic commands */