summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2019-02-08 18:30:59 +0200
committerBen Hutchings <ben@decadent.org.uk>2019-07-09 22:04:00 +0100
commit9ffa96a5554fc1e1d4bf31245c5dbfe2c37e9fe4 (patch)
tree8d54df02df22862f194ad6162ef458d7b9af94a4
parentae46deace3c190e8b84c8f209a64a2d0c753e94f (diff)
downloadlinux-stable-9ffa96a5554fc1e1d4bf31245c5dbfe2c37e9fe4.tar.gz
linux-stable-9ffa96a5554fc1e1d4bf31245c5dbfe2c37e9fe4.tar.bz2
linux-stable-9ffa96a5554fc1e1d4bf31245c5dbfe2c37e9fe4.zip
tpm/tpm_i2c_atmel: Return -E2BIG when the transfer is incomplete
commit 442601e87a4769a8daba4976ec3afa5222ca211d upstream. Return -E2BIG when the transfer is incomplete. The upper layer does not retry, so not doing that is incorrect behaviour. Fixes: a2871c62e186 ("tpm: Add support for Atmel I2C TPMs") Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com> [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--drivers/char/tpm/tpm_i2c_atmel.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/char/tpm/tpm_i2c_atmel.c b/drivers/char/tpm/tpm_i2c_atmel.c
index 503a85ae176c..66c4efa7fca1 100644
--- a/drivers/char/tpm/tpm_i2c_atmel.c
+++ b/drivers/char/tpm/tpm_i2c_atmel.c
@@ -65,7 +65,14 @@ static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len)
dev_dbg(chip->dev,
"%s(buf=%*ph len=%0zx) -> sts=%d\n", __func__,
(int)min_t(size_t, 64, len), buf, len, status);
- return status;
+ if (status < 0)
+ return status;
+
+ /* The upper layer does not support incomplete sends. */
+ if (status != len)
+ return -E2BIG;
+
+ return 0;
}
static int i2c_atmel_recv(struct tpm_chip *chip, u8 *buf, size_t count)