aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm/tpm-interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/tpm/tpm-interface.c')
-rw-r--r--drivers/char/tpm/tpm-interface.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 498809bf1bf0..2b31eff06b0e 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -318,8 +318,7 @@ EXPORT_SYMBOL_GPL(tpm_pcr_read);
318int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, const u8 *hash) 318int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, const u8 *hash)
319{ 319{
320 int rc; 320 int rc;
321 struct tpm2_digest digest_list[ARRAY_SIZE(chip->active_banks)]; 321 struct tpm2_digest *digest_list;
322 u32 count = 0;
323 int i; 322 int i;
324 323
325 chip = tpm_find_get_ops(chip); 324 chip = tpm_find_get_ops(chip);
@@ -327,16 +326,19 @@ int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, const u8 *hash)
327 return -ENODEV; 326 return -ENODEV;
328 327
329 if (chip->flags & TPM_CHIP_FLAG_TPM2) { 328 if (chip->flags & TPM_CHIP_FLAG_TPM2) {
330 memset(digest_list, 0, sizeof(digest_list)); 329 digest_list = kcalloc(chip->nr_allocated_banks,
330 sizeof(*digest_list), GFP_KERNEL);
331 if (!digest_list)
332 return -ENOMEM;
331 333
332 for (i = 0; i < ARRAY_SIZE(chip->active_banks) && 334 for (i = 0; i < chip->nr_allocated_banks; i++) {
333 chip->active_banks[i] != TPM2_ALG_ERROR; i++) { 335 digest_list[i].alg_id = chip->allocated_banks[i];
334 digest_list[i].alg_id = chip->active_banks[i];
335 memcpy(digest_list[i].digest, hash, TPM_DIGEST_SIZE); 336 memcpy(digest_list[i].digest, hash, TPM_DIGEST_SIZE);
336 count++;
337 } 337 }
338 338
339 rc = tpm2_pcr_extend(chip, pcr_idx, count, digest_list); 339 rc = tpm2_pcr_extend(chip, pcr_idx, chip->nr_allocated_banks,
340 digest_list);
341 kfree(digest_list);
340 tpm_put_ops(chip); 342 tpm_put_ops(chip);
341 return rc; 343 return rc;
342 } 344 }