summaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2017-02-03 13:30:40 +0300
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2017-02-03 22:33:55 +0200
commit70ea163699b68963e222a905e184f6436e8a290d (patch)
tree80821aaaa0c0402158a769ad88c03d7437c3069c /drivers/char
parenta118cf2a5b5a0d4541d04e8e8fcde8564803330c (diff)
downloadlinux-70ea163699b68963e222a905e184f6436e8a290d.tar.bz2
tpm: silence an array overflow warning
We should check that we're within bounds first before checking that "chip->active_banks[i] != TPM2_ALG_ERROR" so I've re-ordered the two checks. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/tpm/tpm-interface.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 423938e8570f..087748b8264f 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -800,8 +800,8 @@ int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash)
if (chip->flags & TPM_CHIP_FLAG_TPM2) {
memset(digest_list, 0, sizeof(digest_list));
- for (i = 0; chip->active_banks[i] != TPM2_ALG_ERROR &&
- i < ARRAY_SIZE(chip->active_banks); i++) {
+ for (i = 0; i < ARRAY_SIZE(chip->active_banks) &&
+ chip->active_banks[i] != TPM2_ALG_ERROR; i++) {
digest_list[i].alg_id = chip->active_banks[i];
memcpy(digest_list[i].digest, hash, TPM_DIGEST_SIZE);
count++;