diff mbox

tpm: Prevent a call to TPM if no TPM support is requested

Message ID 1433268322-1290277-1-git-send-email-stefanb@linux.vnet.ibm.com
State New
Headers show

Commit Message

Stefan Berger June 2, 2015, 6:05 p.m. UTC
Prevent the function tpm_tis_get_tpm_version() from being called
if not TPM support is requested.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
 include/sysemu/tpm.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Juan Quintela June 3, 2015, 7:07 a.m. UTC | #1
Stefan Berger <stefanb@linux.vnet.ibm.com> wrote:
> Prevent the function tpm_tis_get_tpm_version() from being called
> if not TPM support is requested.
>
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> ---
>  include/sysemu/tpm.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
> index c143890..c8afa17 100644
> --- a/include/sysemu/tpm.h
> +++ b/include/sysemu/tpm.h
> @@ -32,11 +32,13 @@ TPMVersion tpm_tis_get_tpm_version(Object *obj);
>  
>  static inline TPMVersion tpm_get_version(void)
>  {
> +#ifdef CONFIG_TPM
>      Object *obj = object_resolve_path_type("", TYPE_TPM_TIS, NULL);
>  
>      if (obj) {
>          return tpm_tis_get_tpm_version(obj);
>      }
> +#endif
>      return TPM_VERSION_UNSPEC;
>  }

I sent basically the same patch to mst and to the list.

I don't care which one is picked.

Thanks, Juan.
diff mbox

Patch

diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
index c143890..c8afa17 100644
--- a/include/sysemu/tpm.h
+++ b/include/sysemu/tpm.h
@@ -32,11 +32,13 @@  TPMVersion tpm_tis_get_tpm_version(Object *obj);
 
 static inline TPMVersion tpm_get_version(void)
 {
+#ifdef CONFIG_TPM
     Object *obj = object_resolve_path_type("", TYPE_TPM_TIS, NULL);
 
     if (obj) {
         return tpm_tis_get_tpm_version(obj);
     }
+#endif
     return TPM_VERSION_UNSPEC;
 }