diff mbox series

[v2,3/3] tpm: vtpm_proxy: Avoid reading host log when using a virtual device

Message ID 20210310221916.356716-4-stefanb@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series Fix bugs related to TPM2 event log | expand

Commit Message

Stefan Berger March 10, 2021, 10:19 p.m. UTC
Avoid allocating memory and reading the host log when a virtual device
is used since this log is of no use to that driver. A virtual
device can be identified through the flag TPM_CHIP_FLAG_VIRTUAL, which
is only set for the tpm_vtpm_proxy driver.

Fixes: 6f99612e2500 ("tpm: Proxy driver for supporting multiple emulated TPMs")
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
 drivers/char/tpm/eventlog/common.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Jarkko Sakkinen March 10, 2021, 11:04 p.m. UTC | #1
On Wed, Mar 10, 2021 at 05:19:16PM -0500, Stefan Berger wrote:
> Avoid allocating memory and reading the host log when a virtual device
> is used since this log is of no use to that driver. A virtual
> device can be identified through the flag TPM_CHIP_FLAG_VIRTUAL, which
> is only set for the tpm_vtpm_proxy driver.
> 
> Fixes: 6f99612e2500 ("tpm: Proxy driver for supporting multiple emulated TPMs")
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
> ---
>  drivers/char/tpm/eventlog/common.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/char/tpm/eventlog/common.c b/drivers/char/tpm/eventlog/common.c
> index 7460f230bae4..8512ec76d526 100644
> --- a/drivers/char/tpm/eventlog/common.c
> +++ b/drivers/char/tpm/eventlog/common.c
> @@ -107,6 +107,9 @@ void tpm_bios_log_setup(struct tpm_chip *chip)
>  	int log_version;
>  	int rc = 0;
>  
> +	if (chip->flags & TPM_CHIP_FLAG_VIRTUAL)
> +		return;
> +
>  	rc = tpm_read_log(chip);
>  	if (rc < 0)
>  		return;
> -- 
> 2.29.2
> 
> 


Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>


/Jarkko
diff mbox series

Patch

diff --git a/drivers/char/tpm/eventlog/common.c b/drivers/char/tpm/eventlog/common.c
index 7460f230bae4..8512ec76d526 100644
--- a/drivers/char/tpm/eventlog/common.c
+++ b/drivers/char/tpm/eventlog/common.c
@@ -107,6 +107,9 @@  void tpm_bios_log_setup(struct tpm_chip *chip)
 	int log_version;
 	int rc = 0;
 
+	if (chip->flags & TPM_CHIP_FLAG_VIRTUAL)
+		return;
+
 	rc = tpm_read_log(chip);
 	if (rc < 0)
 		return;