Commit 149d18cc authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Christoph Hellwig

scsi: stop decoding if scsi_normalize_sense() fails

If scsi_normalize_sense() fails we couldn't decode the sense
buffer, and the scsi_sense_hdr fields are invalid.
For those cases we should rather dump the sense buffer
and not try to decode invalid fields.
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarRobert Elliott <elliott@hp.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 7d170907
...@@ -1436,14 +1436,10 @@ scsi_print_sense_hdr(const struct scsi_device *sdev, const char *name, ...@@ -1436,14 +1436,10 @@ scsi_print_sense_hdr(const struct scsi_device *sdev, const char *name,
EXPORT_SYMBOL(scsi_print_sense_hdr); EXPORT_SYMBOL(scsi_print_sense_hdr);
static void static void
scsi_decode_sense_buffer(const unsigned char *sense_buffer, int sense_len, scsi_dump_sense_buffer(const unsigned char *sense_buffer, int sense_len)
struct scsi_sense_hdr *sshdr)
{ {
int k, num, res; int k, num;
res = scsi_normalize_sense(sense_buffer, sense_len, sshdr);
if (0 == res) {
/* this may be SCSI-1 sense data */
num = (sense_len < 32) ? sense_len : 32; num = (sense_len < 32) ? sense_len : 32;
printk("Unrecognized sense data (in hex):"); printk("Unrecognized sense data (in hex):");
for (k = 0; k < num; ++k) { for (k = 0; k < num; ++k) {
...@@ -1455,7 +1451,6 @@ scsi_decode_sense_buffer(const unsigned char *sense_buffer, int sense_len, ...@@ -1455,7 +1451,6 @@ scsi_decode_sense_buffer(const unsigned char *sense_buffer, int sense_len,
} }
printk("\n"); printk("\n");
return; return;
}
} }
static void static void
...@@ -1525,7 +1520,10 @@ void __scsi_print_sense(const struct scsi_device *sdev, const char *name, ...@@ -1525,7 +1520,10 @@ void __scsi_print_sense(const struct scsi_device *sdev, const char *name,
{ {
struct scsi_sense_hdr sshdr; struct scsi_sense_hdr sshdr;
scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr); if (!scsi_normalize_sense(sense_buffer, sense_len, &sshdr)) {
scsi_dump_sense_buffer(sense_buffer, sense_len);
return;
}
scsi_show_sense_hdr(sdev, name, &sshdr); scsi_show_sense_hdr(sdev, name, &sshdr);
scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr); scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr);
scsi_show_extd_sense(sdev, name, sshdr.asc, sshdr.ascq); scsi_show_extd_sense(sdev, name, sshdr.asc, sshdr.ascq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment