aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2014-10-24 08:26:50 -0400
committerChristoph Hellwig <hch@lst.de>2014-11-12 05:16:00 -0500
commit149d18cc2143079ac5fc4e61bc53bb532b8eed26 (patch)
treea335422dc13ba030838e0415a2cccb47d27e1ef0
parent7d170907191ff42d1624fc4a55c2f2400ffec07a (diff)
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: Hannes Reinecke <hare@suse.de> Reviewed-by: Robert Elliott <elliott@hp.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/scsi/constants.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 9065b6f8f51b..d7b6e4bfa55c 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1436,26 +1436,21 @@ scsi_print_sense_hdr(const struct scsi_device *sdev, const char *name,
1436EXPORT_SYMBOL(scsi_print_sense_hdr); 1436EXPORT_SYMBOL(scsi_print_sense_hdr);
1437 1437
1438static void 1438static void
1439scsi_decode_sense_buffer(const unsigned char *sense_buffer, int sense_len, 1439scsi_dump_sense_buffer(const unsigned char *sense_buffer, int sense_len)
1440 struct scsi_sense_hdr *sshdr)
1441{ 1440{
1442 int k, num, res; 1441 int k, num;
1443 1442
1444 res = scsi_normalize_sense(sense_buffer, sense_len, sshdr); 1443 num = (sense_len < 32) ? sense_len : 32;
1445 if (0 == res) { 1444 printk("Unrecognized sense data (in hex):");
1446 /* this may be SCSI-1 sense data */ 1445 for (k = 0; k < num; ++k) {
1447 num = (sense_len < 32) ? sense_len : 32; 1446 if (0 == (k % 16)) {
1448 printk("Unrecognized sense data (in hex):"); 1447 printk("\n");
1449 for (k = 0; k < num; ++k) { 1448 printk(KERN_INFO " ");
1450 if (0 == (k % 16)) {
1451 printk("\n");
1452 printk(KERN_INFO " ");
1453 }
1454 printk("%02x ", sense_buffer[k]);
1455 } 1449 }
1456 printk("\n"); 1450 printk("%02x ", sense_buffer[k]);
1457 return;
1458 } 1451 }
1452 printk("\n");
1453 return;
1459} 1454}
1460 1455
1461static void 1456static void
@@ -1525,7 +1520,10 @@ void __scsi_print_sense(const struct scsi_device *sdev, const char *name,
1525{ 1520{
1526 struct scsi_sense_hdr sshdr; 1521 struct scsi_sense_hdr sshdr;
1527 1522
1528 scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr); 1523 if (!scsi_normalize_sense(sense_buffer, sense_len, &sshdr)) {
1524 scsi_dump_sense_buffer(sense_buffer, sense_len);
1525 return;
1526 }
1529 scsi_show_sense_hdr(sdev, name, &sshdr); 1527 scsi_show_sense_hdr(sdev, name, &sshdr);
1530 scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr); 1528 scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr);
1531 scsi_show_extd_sense(sdev, name, sshdr.asc, sshdr.ascq); 1529 scsi_show_extd_sense(sdev, name, sshdr.asc, sshdr.ascq);