Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9b80cb4be1f4181875e0cf274dc59f42964fdf1b
Commit:     9b80cb4be1f4181875e0cf274dc59f42964fdf1b
Parent:     94cb3f822bb806a750e1e1c8457bee6e96671569
Author:     Mike Christie <[EMAIL PROTECTED]>
AuthorDate: Sun Dec 17 12:10:28 2006 -0600
Committer:  James Bottomley <[EMAIL PROTECTED]>
CommitDate: Sat Jan 6 09:02:09 2007 -0600

    [SCSI] libiscsi: fix senselen calculation
    
    Yanling Qi, noted that when the sense data length of
    a check-condition is greater than 0x7f (127), senselen = (data[0] << 8)
    | data[1] will become negative. It causes different kinds of panics from
    GPF, spin_lock deadlock to spin_lock recursion.
    
    We were also swapping this value on big endien machines.
    
    This patch fixes both issues by using be16_to_cpu().
    
    Signed-off-by: Mike Christie <[EMAIL PROTECTED]>
    Signed-off-by: James Bottomley <[EMAIL PROTECTED]>
---
 drivers/scsi/libiscsi.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index e11b23c..d37048c 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -260,7 +260,7 @@ static int iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, 
struct iscsi_hdr *hdr,
        }
 
        if (rhdr->cmd_status == SAM_STAT_CHECK_CONDITION) {
-               int senselen;
+               uint16_t senselen;
 
                if (datalen < 2) {
 invalid_datalen:
@@ -270,12 +270,12 @@ invalid_datalen:
                        goto out;
                }
 
-               senselen = (data[0] << 8) | data[1];
+               senselen = be16_to_cpu(*(uint16_t *)data);
                if (datalen < senselen)
                        goto invalid_datalen;
 
                memcpy(sc->sense_buffer, data + 2,
-                      min(senselen, SCSI_SENSE_BUFFERSIZE));
+                      min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE));
                debug_scsi("copied %d bytes of sense\n",
                           min(senselen, SCSI_SENSE_BUFFERSIZE));
        }
-
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