tpm: Call tpm_put_ops() when the validation for @digests fails
Subsystems (3)
PATCH 1/1 tpm: Call tpm_put_ops() when the validation for @digests fails
The chip is not released when the validation for @digests fails. Add tpm_put_ops() to the failure path.
Reported-by Roberto Sassu <[email protected]>
Signed-off-by Jarkko Sakkinen <[email protected]>
--- drivers/char/tpm/tpm-interface.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/char/tpm/tpm-interface.c +9 -5
@@ -320,18 +320,22 @@ int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx,if (!chip)return -ENODEV ; -for (i =0 ; i < chip->nr_allocated_banks; i++) -if (digests[i].alg_id != chip->allocated_banks[i].alg_id) -return -EINVAL ; +for (i =0 ; i < chip->nr_allocated_banks; i++) { +if (digests[i].alg_id != chip->allocated_banks[i].alg_id) { + rc =EINVAL ; + goto out; + } + }if (chip->flags &TPM_CHIP_FLAG_TPM2 ) { rc =tpm2_pcr_extend (chip, pcr_idx, digests); -tpm_put_ops (chip); -return rc; + goto out; } rc =tpm1_pcr_extend (chip, pcr_idx, digests[0 ].digest,"attempting extend a PCR value" ); + +out:tpm_put_ops (chip);return rc; }
Signature · 1 line
2.20.1
Quoted 6 lines · Jarkko Sakkinen
The chip is not released when the validation for @digests fails. Add
tpm_put_ops()to the failure path.Reported-by Roberto Sassu <[email protected]>Signed-off-by Jarkko Sakkinen <[email protected]>
Reviewed-by Jerry Snitselaar <[email protected]>
Quoted 39 lines
---
drivers/char/tpm/tpm-interface.c| 14 +++++++++-----1 file changed, 9 insertions(+), 5 deletions(-)drivers/char/tpm/tpm-interface.c +9
-5@@ -320,18 +320,22 @@ int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx,if (!chip)return -ENODEV ; -for (i =0 ; i < chip->nr_allocated_banks; i++) -if (digests[i].alg_id != chip->allocated_banks[i].alg_id) -return -EINVAL ; +for (i =0 ; i < chip->nr_allocated_banks; i++) { +if (digests[i].alg_id != chip->allocated_banks[i].alg_id) { + rc =EINVAL ; + goto out; + } + }if (chip->flags &TPM_CHIP_FLAG_TPM2 ) { rc =tpm2_pcr_extend (chip, pcr_idx, digests); -tpm_put_ops (chip); -return rc; + goto out; } rc =tpm1_pcr_extend (chip, pcr_idx, digests[0 ].digest,"attempting extend a PCR value" ); + +out:tpm_put_ops (chip);return rc; }Signature · 1 line
2.20.1
Quoted 9 lines · Jerry Snitselaar
Quoted 6 lines · Jarkko Sakkinen
The chip is not released when the validation for @digests fails. Add
tpm_put_ops()to the failure path.Reported-by Roberto Sassu <[email protected]>Signed-off-by Jarkko Sakkinen <[email protected]>Reviewed-by Jerry Snitselaar <[email protected]>
Roberto, can you just squash this fix with yours to a single patch and send a new patch version? You can add suggested-by tag from me to v4.
/Jarkko