]> git.proxmox.com Git - mirror_qemu.git/commitdiff
tpm: Implement tpm_sized_buffer_reset
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Wed, 11 Oct 2017 14:36:53 +0000 (10:36 -0400)
committerStefan Berger <stefanb@linux.vnet.ibm.com>
Fri, 22 Dec 2017 14:01:09 +0000 (09:01 -0500)
Move the definition of TPMSizedBuffer out of tpm_tis.c into tpm_util.h
and implement tpm_sized_buffer_reset() for the following patches to use.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
hw/tpm/tpm_tis.c
hw/tpm/tpm_util.c
hw/tpm/tpm_util.h

index ac5d5c61be3ce49cf8e162f3e535e20e7ba97352..561384cd8677a5851b0621075005ba6d6d6eced7 100644 (file)
@@ -48,11 +48,6 @@ typedef enum {
     TPM_TIS_STATE_RECEPTION,
 } TPMTISState;
 
-typedef struct TPMSizedBuffer {
-    uint32_t size;
-    uint8_t  *buffer;
-} TPMSizedBuffer;
-
 /* locality data  -- all fields are persisted */
 typedef struct TPMLocality {
     TPMTISState state;
index 17cafbe6b303f037f11bf6759fda62eec1261a85..747075e2442b0659e0a2bab73addf6c0aa03efb5 100644 (file)
@@ -355,3 +355,10 @@ int tpm_util_get_buffer_size(int tpm_fd, TPMVersion tpm_version,
 
     return 0;
 }
+
+void tpm_sized_buffer_reset(TPMSizedBuffer *tsb)
+{
+    g_free(tsb->buffer);
+    tsb->buffer = NULL;
+    tsb->size = 0;
+}
index 2393b6bc0e4c432162a063d04d6421c4cca6b0da..19b28474ae9a31086143e5c6840055e655433627 100644 (file)
@@ -42,4 +42,11 @@ int tpm_util_get_buffer_size(int tpm_fd, TPMVersion tpm_version,
 #define DEFINE_PROP_TPMBE(_n, _s, _f)                     \
     DEFINE_PROP(_n, _s, _f, qdev_prop_tpm, TPMBackend *)
 
+typedef struct TPMSizedBuffer {
+    uint32_t size;
+    uint8_t  *buffer;
+} TPMSizedBuffer;
+
+void tpm_sized_buffer_reset(TPMSizedBuffer *tsb);
+
 #endif /* TPM_TPM_UTIL_H */