]> git.hungrycats.org Git - linux/commitdiff
tpm/tpm_i2c_stm_st33: Add status check when reading data on the FIFO
authorChristophe Ricard <christophe.ricard@gmail.com>
Tue, 13 Jan 2015 22:13:14 +0000 (23:13 +0100)
committerSasha Levin <sasha.levin@oracle.com>
Sat, 28 Mar 2015 13:43:13 +0000 (09:43 -0400)
[ Upstream commit c4eadfafb91d5501095c55ffadaa1168743f39d3 ]

Add a return value check when reading data from the FIFO register.

Cc: <stable@vger.kernel.org>
Reviewed-by: Jason Gunthorpe <jason.gunthorpe@obsidianresearch.com>
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
drivers/char/tpm/tpm_i2c_stm_st33.c

index 7d1c540fa26a8987f7f5c021ff89e0ec28467961..3f187a529e9299a71543b010a0dc6f699de57f3f 100644 (file)
@@ -397,7 +397,7 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
  */
 static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
 {
-       int size = 0, burstcnt, len;
+       int size = 0, burstcnt, len, ret;
        struct i2c_client *client;
 
        client = (struct i2c_client *)TPM_VPRIV(chip);
@@ -406,13 +406,15 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
               wait_for_stat(chip,
                             TPM_STS_DATA_AVAIL | TPM_STS_VALID,
                             chip->vendor.timeout_c,
-                            &chip->vendor.read_queue)
-              == 0) {
+                            &chip->vendor.read_queue) == 0) {
                burstcnt = get_burstcount(chip);
                if (burstcnt < 0)
                        return burstcnt;
                len = min_t(int, burstcnt, count - size);
-               I2C_READ_DATA(client, TPM_DATA_FIFO, buf + size, len);
+               ret = I2C_READ_DATA(client, TPM_DATA_FIFO, buf + size, len);
+               if (ret < 0)
+                       return ret;
+
                size += len;
        }
        return size;