Skip to content

Commit

Permalink
tpm: Implement tpm_sized_buffer_reset
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
stefanberger committed Dec 22, 2017
1 parent f999d81 commit b86da7d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 0 additions & 5 deletions hw/tpm/tpm_tis.c
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions hw/tpm/tpm_util.c
Expand Up @@ -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;
}
7 changes: 7 additions & 0 deletions hw/tpm/tpm_util.h
Expand Up @@ -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 */

0 comments on commit b86da7d

Please sign in to comment.