diff mbox series

[v3,2/3] tpm: Make sure new locality passed to tpm_tis_prep_abort() is valid

Message ID 20181204150427.2459814-3-stefanb@linux.vnet.ibm.com
State New
Headers show
Series Cleanup and locality range check | expand

Commit Message

Stefan Berger Dec. 4, 2018, 3:04 p.m. UTC
Make sure that the new locality passed to tpm_tis_prep_abort()
is valid.

Add a comment to aborting_locty that it may be any locality, including
TPM_TIS_NO_LOCALITY.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
 hw/tpm/tpm_tis.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Marc-André Lureau Dec. 4, 2018, 3:19 p.m. UTC | #1
On Tue, Dec 4, 2018 at 7:04 PM Stefan Berger <stefanb@linux.vnet.ibm.com> wrote:
>
> Make sure that the new locality passed to tpm_tis_prep_abort()
> is valid.
>
> Add a comment to aborting_locty that it may be any locality, including
> TPM_TIS_NO_LOCALITY.
>
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  hw/tpm/tpm_tis.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
> index 176d424ed9..04e4ad9212 100644
> --- a/hw/tpm/tpm_tis.c
> +++ b/hw/tpm/tpm_tis.c
> @@ -263,7 +263,9 @@ static void tpm_tis_prep_abort(TPMState *s, uint8_t locty, uint8_t newlocty)
>  {
>      uint8_t busy_locty;
>
> -    s->aborting_locty = locty;
> +    assert(TPM_TIS_IS_VALID_LOCTY(newlocty));
> +
> +    s->aborting_locty = locty; /* may also be TPM_TIS_NO_LOCALITY */
>      s->next_locty = newlocty;  /* locality after successful abort */
>
>      /*
> --
> 2.17.1
>
diff mbox series

Patch

diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index 176d424ed9..04e4ad9212 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -263,7 +263,9 @@  static void tpm_tis_prep_abort(TPMState *s, uint8_t locty, uint8_t newlocty)
 {
     uint8_t busy_locty;
 
-    s->aborting_locty = locty;
+    assert(TPM_TIS_IS_VALID_LOCTY(newlocty));
+
+    s->aborting_locty = locty; /* may also be TPM_TIS_NO_LOCALITY */
     s->next_locty = newlocty;  /* locality after successful abort */
 
     /*