diff options
author | Dan Streetman <ddstreet@ieee.org> | 2023-01-23 19:52:56 -0500 |
---|---|---|
committer | Dan Streetman <ddstreet@ieee.org> | 2023-02-01 12:51:17 -0500 |
commit | 68d084cee56e2686fb840106de20e267482183be (patch) | |
tree | 7d56e860be25458e9b4640baa57c45a2ef22275b /src/cryptsetup/cryptsetup.c | |
parent | bd860983a6f884e37e88915f545d5520f92890ec (diff) | |
download | systemd-68d084cee56e2686fb840106de20e267482183be.tar.gz |
tpm2: use ref counter for Tpm2Context
This will be used by Tpm2Handle instances, which is added in later patches.
The refcounting allows the context to be retained until all Tpm2Handles have
been cleaned up, and the initial ref is released, before cleaning the context.
Diffstat (limited to 'src/cryptsetup/cryptsetup.c')
-rw-r--r-- | src/cryptsetup/cryptsetup.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index 27d7c2769a..845667eabe 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -841,14 +841,14 @@ static int measure_volume_key( if (r < 0) return log_error_errno(r, "Failed to load TPM2 libraries: %m"); - _cleanup_(tpm2_context_destroy) Tpm2Context c = {}; - r = tpm2_context_init(arg_tpm2_device, &c); + _cleanup_tpm2_context_ Tpm2Context *c = NULL; + r = tpm2_context_new(arg_tpm2_device, &c); if (r < 0) return r; _cleanup_strv_free_ char **l = NULL; if (strv_isempty(arg_tpm2_measure_banks)) { - r = tpm2_get_good_pcr_banks_strv(c.esys_context, UINT32_C(1) << arg_tpm2_measure_pcr, &l); + r = tpm2_get_good_pcr_banks_strv(c->esys_context, UINT32_C(1) << arg_tpm2_measure_pcr, &l); if (r < 0) return r; } @@ -871,7 +871,7 @@ static int measure_volume_key( if (!s) return log_oom(); - r = tpm2_extend_bytes(c.esys_context, l ?: arg_tpm2_measure_banks, arg_tpm2_measure_pcr, s, SIZE_MAX, volume_key, volume_key_size); + r = tpm2_extend_bytes(c->esys_context, l ?: arg_tpm2_measure_banks, arg_tpm2_measure_pcr, s, SIZE_MAX, volume_key, volume_key_size); if (r < 0) return r; |