aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorRajiv Andrade <srajiv@linux.vnet.ibm.com>2011-11-01 15:00:52 -0400
committerRajiv Andrade <srajiv@linux.vnet.ibm.com>2011-11-16 06:57:11 -0500
commitb9e3238aa36db33aa0d0bd44ef85297c45627aac (patch)
tree5c9d90539b5730df66d8dfa26f025b2be898a006 /drivers/char
parent2f592f2a7d74c66763a6903edd04109132674d73 (diff)
TPM: fix transmit_cmd error logic
It's incorrect to assume that buffers returned by the TPM 10 bytes long are always error reports. This patches parses the error field in its header instead. The error report is now being printed using dev_err() instead of dev_dbg(), making it easier for users to provide more detailed bug reports. Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/tpm/tpm.c15
-rw-r--r--drivers/char/tpm/tpm.h2
-rw-r--r--drivers/char/tpm/tpm_tis.c2
3 files changed, 9 insertions, 10 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index efd24bbb5cb1..67335af0ec2a 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -438,7 +438,6 @@ out:
438} 438}
439 439
440#define TPM_DIGEST_SIZE 20 440#define TPM_DIGEST_SIZE 20
441#define TPM_ERROR_SIZE 10
442#define TPM_RET_CODE_IDX 6 441#define TPM_RET_CODE_IDX 6
443 442
444enum tpm_capabilities { 443enum tpm_capabilities {
@@ -467,12 +466,14 @@ static ssize_t transmit_cmd(struct tpm_chip *chip, struct tpm_cmd_t *cmd,
467 len = tpm_transmit(chip,(u8 *) cmd, len); 466 len = tpm_transmit(chip,(u8 *) cmd, len);
468 if (len < 0) 467 if (len < 0)
469 return len; 468 return len;
470 if (len == TPM_ERROR_SIZE) { 469 else if (len < TPM_HEADER_SIZE)
471 err = be32_to_cpu(cmd->header.out.return_code); 470 return -EFAULT;
472 dev_dbg(chip->dev, "A TPM error (%d) occurred %s\n", err, desc); 471
473 return err; 472 err = be32_to_cpu(cmd->header.out.return_code);
474 } 473 if (err != 0)
475 return 0; 474 dev_err(chip->dev, "A TPM error (%d) occurred %s\n", err, desc);
475
476 return err;
476} 477}
477 478
478#define TPM_INTERNAL_RESULT_SIZE 200 479#define TPM_INTERNAL_RESULT_SIZE 200
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 9deb65c0ab61..8c1df302fbb6 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -39,7 +39,7 @@ enum tpm_addr {
39}; 39};
40 40
41#define TPM_WARN_DOING_SELFTEST 0x802 41#define TPM_WARN_DOING_SELFTEST 0x802
42 42#define TPM_HEADER_SIZE 10
43extern ssize_t tpm_show_pubek(struct device *, struct device_attribute *attr, 43extern ssize_t tpm_show_pubek(struct device *, struct device_attribute *attr,
44 char *); 44 char *);
45extern ssize_t tpm_show_pcrs(struct device *, struct device_attribute *attr, 45extern ssize_t tpm_show_pcrs(struct device *, struct device_attribute *attr,
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 92f9f34e88f7..10cc44ceb5d1 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -29,8 +29,6 @@
29#include <linux/freezer.h> 29#include <linux/freezer.h>
30#include "tpm.h" 30#include "tpm.h"
31 31
32#define TPM_HEADER_SIZE 10
33
34enum tis_access { 32enum tis_access {
35 TPM_ACCESS_VALID = 0x80, 33 TPM_ACCESS_VALID = 0x80,
36 TPM_ACCESS_ACTIVE_LOCALITY = 0x20, 34 TPM_ACCESS_ACTIVE_LOCALITY = 0x20,