Skip to content

Commit 32a0c86

Browse files
webmeisterjarkkojs
authored andcommitted
tpm_tis: Move CRC check to generic send routine
The CRC functionality is initialized before tpm_tis_core, so it can be used on all code paths within the module. Therefore, move the CRC check to the generic send routine, that also contains all other checks for successful command transmission, so that all those checks are in one place. Also, this ensures that tpm_tis_ready is called when a CRC failure is detected, to clear the invalid data from the TPM, which did not happen previously. Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
1 parent a86a42a commit 32a0c86

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

drivers/char/tpm/tpm_tis_core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,12 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
469469
goto out_err;
470470
}
471471

472+
rc = tpm_tis_verify_crc(priv, len, buf);
473+
if (rc < 0) {
474+
dev_err(&chip->dev, "CRC mismatch for command.\n");
475+
goto out_err;
476+
}
477+
472478
return 0;
473479

474480
out_err:
@@ -517,12 +523,6 @@ static int tpm_tis_send_main(struct tpm_chip *chip, const u8 *buf, size_t len)
517523
if (rc < 0)
518524
return rc;
519525

520-
rc = tpm_tis_verify_crc(priv, len, buf);
521-
if (rc < 0) {
522-
dev_err(&chip->dev, "CRC mismatch for command.\n");
523-
return rc;
524-
}
525-
526526
/* go and do it */
527527
rc = tpm_tis_write8(priv, TPM_STS(priv->locality), TPM_STS_GO);
528528
if (rc < 0)

0 commit comments

Comments
 (0)