Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b9e3238a authored by Rajiv Andrade's avatar Rajiv Andrade
Browse files

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: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
parent 2f592f2a
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -438,7 +438,6 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
}

#define TPM_DIGEST_SIZE 20
#define TPM_ERROR_SIZE 10
#define TPM_RET_CODE_IDX 6

enum tpm_capabilities {
@@ -467,13 +466,15 @@ static ssize_t transmit_cmd(struct tpm_chip *chip, struct tpm_cmd_t *cmd,
	len = tpm_transmit(chip,(u8 *) cmd, len);
	if (len <  0)
		return len;
	if (len == TPM_ERROR_SIZE) {
	else if (len < TPM_HEADER_SIZE)
		return -EFAULT;

	err = be32_to_cpu(cmd->header.out.return_code);
		dev_dbg(chip->dev, "A TPM error (%d) occurred %s\n", err, desc);
	if (err != 0)
		dev_err(chip->dev, "A TPM error (%d) occurred %s\n", err, desc);

	return err;
}
	return 0;
}

#define TPM_INTERNAL_RESULT_SIZE 200
#define TPM_TAG_RQU_COMMAND cpu_to_be16(193)
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ enum tpm_addr {
};

#define TPM_WARN_DOING_SELFTEST 0x802

#define TPM_HEADER_SIZE		10
extern ssize_t tpm_show_pubek(struct device *, struct device_attribute *attr,
				char *);
extern ssize_t tpm_show_pcrs(struct device *, struct device_attribute *attr,
+0 −2
Original line number Diff line number Diff line
@@ -29,8 +29,6 @@
#include <linux/freezer.h>
#include "tpm.h"

#define TPM_HEADER_SIZE 10

enum tis_access {
	TPM_ACCESS_VALID = 0x80,
	TPM_ACCESS_ACTIVE_LOCALITY = 0x20,