summaryrefslogtreecommitdiff
path: root/lib/tpm2.c
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2021-11-14 14:57:15 +0100
committerDaiki Ueno <ueno@gnu.org>2021-11-17 08:08:29 +0100
commit90bbc9b76d381bccbfe370f1926941b35b5b56ec (patch)
tree0540a1ee9079cfa755b929eea86aa15c0f6f2b34 /lib/tpm2.c
parentbcffed047f7a228cf99028eb2b8249e5a02eb2e6 (diff)
downloadgnutls-90bbc9b76d381bccbfe370f1926941b35b5b56ec.tar.gz
locks: use once execution for on-demand initialization of globals
This makes sure that the global variables are initialized only once. Most of those variables are initialized at ELF constructor, though a couple of occasions they are initialized on-demand: the global keylog file pointer and TPM2 TCTI context. To properly protect the initialization this patch uses gl_once provided by Gnulib. Signed-off-by: Daiki Ueno <ueno@gnu.org>
Diffstat (limited to 'lib/tpm2.c')
-rw-r--r--lib/tpm2.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/tpm2.c b/lib/tpm2.c
index 5c293a553c..076cc7f407 100644
--- a/lib/tpm2.c
+++ b/lib/tpm2.c
@@ -294,3 +294,8 @@ int _gnutls_load_tpm2_key(gnutls_privkey_t pkey, const gnutls_datum_t *fdata)
gnutls_free(asn1.data);
return ret;
}
+
+void _gnutls_tpm2_deinit(void)
+{
+ tpm2_tcti_deinit();
+}