summaryrefslogtreecommitdiff
path: root/src/boot/pcrphase.c
diff options
context:
space:
mode:
authorDan Streetman <ddstreet@ieee.org>2023-01-23 19:52:56 -0500
committerDan Streetman <ddstreet@ieee.org>2023-02-01 12:51:17 -0500
commit68d084cee56e2686fb840106de20e267482183be (patch)
tree7d56e860be25458e9b4640baa57c45a2ef22275b /src/boot/pcrphase.c
parentbd860983a6f884e37e88915f545d5520f92890ec (diff)
downloadsystemd-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/boot/pcrphase.c')
-rw-r--r--src/boot/pcrphase.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/boot/pcrphase.c b/src/boot/pcrphase.c
index 057b9f495c..dc5604a33c 100644
--- a/src/boot/pcrphase.c
+++ b/src/boot/pcrphase.c
@@ -240,7 +240,6 @@ static int get_file_system_word(
}
static int run(int argc, char *argv[]) {
- _cleanup_(tpm2_context_destroy) Tpm2Context c = {};
_cleanup_free_ char *joined = NULL, *word = NULL;
unsigned target_pcr_nr;
size_t length;
@@ -346,11 +345,12 @@ static int run(int argc, char *argv[]) {
if (r < 0)
return log_error_errno(r, "Failed to load TPM2 libraries: %m");
- 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;
- r = determine_banks(&c, target_pcr_nr);
+ r = determine_banks(c, target_pcr_nr);
if (r < 0)
return r;
if (strv_isempty(arg_banks)) /* Still none? */
@@ -362,7 +362,7 @@ static int run(int argc, char *argv[]) {
log_debug("Measuring '%s' into PCR index %u, banks %s.", word, target_pcr_nr, joined);
- r = tpm2_extend_bytes(c.esys_context, arg_banks, target_pcr_nr, word, length, NULL, 0);
+ r = tpm2_extend_bytes(c->esys_context, arg_banks, target_pcr_nr, word, length, NULL, 0);
if (r < 0)
return r;