diff mbox series

[1/2] tpm: Exit in reset when backend indicates failure

Message ID 20190725105842.872625-2-stefanb@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show
Series tpm: Improve on error handling | expand

Commit Message

Stefan Berger July 25, 2019, 10:58 a.m. UTC
Exit() in the frontend reset function when the backend indicates
intialization failure.

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

Comments

Marc-André Lureau July 25, 2019, 11:34 a.m. UTC | #1
On Thu, Jul 25, 2019 at 2:58 PM Stefan Berger
<stefanb@linux.vnet.ibm.com> wrote:
>
> Exit() in the frontend reset function when the backend indicates
> intialization failure.
>
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>

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

> ---
>  hw/tpm/tpm_crb.c | 4 +++-
>  hw/tpm/tpm_tis.c | 4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
> index 5e2db9e0c4..db0e3e7c67 100644
> --- a/hw/tpm/tpm_crb.c
> +++ b/hw/tpm/tpm_crb.c
> @@ -273,7 +273,9 @@ static void tpm_crb_reset(void *dev)
>      s->be_buffer_size = MIN(tpm_backend_get_buffer_size(s->tpmbe),
>                              CRB_CTRL_CMD_SIZE);
>
> -    tpm_backend_startup_tpm(s->tpmbe, s->be_buffer_size);
> +    if (tpm_backend_startup_tpm(s->tpmbe, s->be_buffer_size) < 0) {
> +        exit(1);
> +    }
>  }
>
>  static void tpm_crb_realize(DeviceState *dev, Error **errp)
> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
> index 174618ac30..d6b3212890 100644
> --- a/hw/tpm/tpm_tis.c
> +++ b/hw/tpm/tpm_tis.c
> @@ -910,7 +910,9 @@ static void tpm_tis_reset(DeviceState *dev)
>          s->rw_offset = 0;
>      }
>
> -    tpm_backend_startup_tpm(s->be_driver, s->be_buffer_size);
> +    if (tpm_backend_startup_tpm(s->be_driver, s->be_buffer_size) < 0) {
> +        exit(1);
> +    }
>  }
>
>  /* persistent state handling */
> --
> 2.20.1
>
diff mbox series

Patch

diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
index 5e2db9e0c4..db0e3e7c67 100644
--- a/hw/tpm/tpm_crb.c
+++ b/hw/tpm/tpm_crb.c
@@ -273,7 +273,9 @@  static void tpm_crb_reset(void *dev)
     s->be_buffer_size = MIN(tpm_backend_get_buffer_size(s->tpmbe),
                             CRB_CTRL_CMD_SIZE);
 
-    tpm_backend_startup_tpm(s->tpmbe, s->be_buffer_size);
+    if (tpm_backend_startup_tpm(s->tpmbe, s->be_buffer_size) < 0) {
+        exit(1);
+    }
 }
 
 static void tpm_crb_realize(DeviceState *dev, Error **errp)
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index 174618ac30..d6b3212890 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -910,7 +910,9 @@  static void tpm_tis_reset(DeviceState *dev)
         s->rw_offset = 0;
     }
 
-    tpm_backend_startup_tpm(s->be_driver, s->be_buffer_size);
+    if (tpm_backend_startup_tpm(s->be_driver, s->be_buffer_size) < 0) {
+        exit(1);
+    }
 }
 
 /* persistent state handling */