Skip to content

Commit

Permalink
tpm_i2c_nuvoton: fix tpm_read_fifo overflow check
Browse files Browse the repository at this point in the history
The tpm_read_fifo expects buflen parameter which is the size of buf
parameter. Later it uses buflen to check for an overflow in the case tpm
response is bigger than buf capacity.

The check is fine, but it doesn't interrupt the code flow, so even though
we see error messages about the overflow, it doesn't prevent it.

Adding a goto after specifying the error return code fixes it.

Signed-off-by: Mauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com>
Reviewed-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
Reviewed-by: Claudio Carvalho <cclaudio@linux.ibm.com>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
  • Loading branch information
maurorodrigues authored and oohal committed Mar 11, 2020
1 parent 82aed17 commit e4113f9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions libstb/drivers/tpm_i2c_nuvoton.c
Expand Up @@ -383,6 +383,7 @@ static int tpm_read_fifo(uint8_t* buf, size_t* buflen)
prlog(PR_ERR, "NUVOTON: overflow on fifo read, c=%zd, "
"bc=%d, bl=%zd\n", count, burst_count, *buflen);
rc = STB_TPM_OVERFLOW;
goto error;
}
rc = tpm_i2c_request_send(tpm_device,
SMBUS_READ,
Expand Down

0 comments on commit e4113f9

Please sign in to comment.