diff mbox series

[v3,3/3] tpm: Make sure the locality received from backend is valid

Message ID 20181204150427.2459814-4-stefanb@linux.vnet.ibm.com (mailing list archive)
State New, archived
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 locality passed from the backend to
tpm_tis_request_completed() is valid.

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

Comments

Marc-André Lureau Dec. 4, 2018, 3:20 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 locality passed from the backend to
> tpm_tis_request_completed() is valid.
>
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>

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

> ---
>  hw/tpm/tpm_tis.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
> index 04e4ad9212..2563d7501f 100644
> --- a/hw/tpm/tpm_tis.c
> +++ b/hw/tpm/tpm_tis.c
> @@ -295,6 +295,8 @@ static void tpm_tis_request_completed(TPMIf *ti, int ret)
>      uint8_t locty = s->cmd.locty;
>      uint8_t l;
>
> +    assert(TPM_TIS_IS_VALID_LOCTY(locty));
> +
>      if (s->cmd.selftest_done) {
>          for (l = 0; l < TPM_TIS_NUM_LOCALITIES; l++) {
>              s->loc[l].sts |= TPM_TIS_STS_SELFTEST_DONE;
> --
> 2.17.1
>
diff mbox series

Patch

diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index 04e4ad9212..2563d7501f 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -295,6 +295,8 @@  static void tpm_tis_request_completed(TPMIf *ti, int ret)
     uint8_t locty = s->cmd.locty;
     uint8_t l;
 
+    assert(TPM_TIS_IS_VALID_LOCTY(locty));
+
     if (s->cmd.selftest_done) {
         for (l = 0; l < TPM_TIS_NUM_LOCALITIES; l++) {
             s->loc[l].sts |= TPM_TIS_STS_SELFTEST_DONE;