summaryrefslogtreecommitdiff
path: root/drivers/scsi/constants.c
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2014-10-24 14:26:50 +0200
committerChristoph Hellwig <hch@lst.de>2014-11-12 11:16:00 +0100
commit149d18cc2143079ac5fc4e61bc53bb532b8eed26 (patch)
treea335422dc13ba030838e0415a2cccb47d27e1ef0 /drivers/scsi/constants.c
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>
Diffstat (limited to 'drivers/scsi/constants.c')
-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,
EXPORT_SYMBOL(scsi_print_sense_hdr);
static void
-scsi_decode_sense_buffer(const unsigned char *sense_buffer, int sense_len,
- struct scsi_sense_hdr *sshdr)
+scsi_dump_sense_buffer(const unsigned char *sense_buffer, int sense_len)
{
- int k, num, res;
-
- 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;
- printk("Unrecognized sense data (in hex):");
- for (k = 0; k < num; ++k) {
- if (0 == (k % 16)) {
- printk("\n");
- printk(KERN_INFO " ");
- }
- printk("%02x ", sense_buffer[k]);
+ int k, num;
+
+ num = (sense_len < 32) ? sense_len : 32;
+ printk("Unrecognized sense data (in hex):");
+ for (k = 0; k < num; ++k) {
+ if (0 == (k % 16)) {
+ printk("\n");
+ printk(KERN_INFO " ");
}
- printk("\n");
- return;
+ printk("%02x ", sense_buffer[k]);
}
+ printk("\n");
+ return;
}
static void
@@ -1525,7 +1520,10 @@ void __scsi_print_sense(const struct scsi_device *sdev, const char *name,
{
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_decode_sense_extras(sense_buffer, sense_len, &sshdr);
scsi_show_extd_sense(sdev, name, sshdr.asc, sshdr.ascq);