提交 70ea1636 编写于 作者: D Dan Carpenter 提交者: Jarkko Sakkinen

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: NDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: NJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: NJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
上级 a118cf2a
...@@ -800,8 +800,8 @@ int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash) ...@@ -800,8 +800,8 @@ int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash)
if (chip->flags & TPM_CHIP_FLAG_TPM2) { if (chip->flags & TPM_CHIP_FLAG_TPM2) {
memset(digest_list, 0, sizeof(digest_list)); memset(digest_list, 0, sizeof(digest_list));
for (i = 0; chip->active_banks[i] != TPM2_ALG_ERROR && for (i = 0; i < ARRAY_SIZE(chip->active_banks) &&
i < ARRAY_SIZE(chip->active_banks); i++) { chip->active_banks[i] != TPM2_ALG_ERROR; i++) {
digest_list[i].alg_id = chip->active_banks[i]; digest_list[i].alg_id = chip->active_banks[i];
memcpy(digest_list[i].digest, hash, TPM_DIGEST_SIZE); memcpy(digest_list[i].digest, hash, TPM_DIGEST_SIZE);
count++; count++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册