scsi: always zero sshdr in scsi_normalize_sense
authorChristoph Hellwig <hch@lst.de>
Tue, 14 Feb 2017 19:15:55 +0000 (20:15 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 23 Feb 2017 00:33:00 +0000 (19:33 -0500)
This gives us a clear state even if a command didn't return sense data.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_common.c

index b1383a71400ead097e9e0c6b67d48406525dd196..a75673bb82b393191fd6cbbeedeecd2f15a3a4f0 100644 (file)
@@ -137,11 +137,11 @@ EXPORT_SYMBOL(int_to_scsilun);
 bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
                          struct scsi_sense_hdr *sshdr)
 {
+       memset(sshdr, 0, sizeof(struct scsi_sense_hdr));
+
        if (!sense_buffer || !sb_len)
                return false;
 
-       memset(sshdr, 0, sizeof(struct scsi_sense_hdr));
-
        sshdr->response_code = (sense_buffer[0] & 0x7f);
 
        if (!scsi_sense_valid(sshdr))