Message ID | 20181203170105.2367492-3-stefanb@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Cleanup and locality range check | expand |
Hi On Mon, Dec 3, 2018 at 9:01 PM Stefan Berger <stefanb@linux.vnet.ibm.com> wrote: > > Make sure that the new locality passed to tpm_tis_prep_abort() > is valid. This is merely a precaution since none of the current > callers passes an invalid locality number into this function. If this should never happen, then let's make it an assert() > 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 | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c > index 176d424ed9..9b2737b5bf 100644 > --- a/hw/tpm/tpm_tis.c > +++ b/hw/tpm/tpm_tis.c > @@ -263,7 +263,10 @@ static void tpm_tis_prep_abort(TPMState *s, uint8_t locty, uint8_t newlocty) > { > uint8_t busy_locty; > > - s->aborting_locty = locty; > + if (!TPM_TIS_IS_VALID_LOCTY(newlocty)) > + return; Follow qemu coding-style, add braces. > + > + s->aborting_locty = locty; /* may also be TPM_TIS_NO_LOCALITY */ > s->next_locty = newlocty; /* locality after successful abort */ > > /* > -- > 2.17.1 >
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 176d424ed9..9b2737b5bf 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -263,7 +263,10 @@ static void tpm_tis_prep_abort(TPMState *s, uint8_t locty, uint8_t newlocty) { uint8_t busy_locty; - s->aborting_locty = locty; + if (!TPM_TIS_IS_VALID_LOCTY(newlocty)) + return; + + s->aborting_locty = locty; /* may also be TPM_TIS_NO_LOCALITY */ s->next_locty = newlocty; /* locality after successful abort */ /*
Make sure that the new locality passed to tpm_tis_prep_abort() is valid. This is merely a precaution since none of the current callers passes an invalid locality number into this function. 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)