]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cryptsetup: Fix memory leak when iterating over systemd-tpm2 tokens
authorGabríel Arthúr Pétursson <gabriel.petursson@marel.com>
Wed, 3 Jan 2024 16:20:04 +0000 (16:20 +0000)
committerGabríel Arthúr Pétursson <gabriel.petursson@marel.com>
Thu, 1 Feb 2024 12:20:00 +0000 (12:20 +0000)
src/cryptsetup/cryptsetup.c

index 0840a71548b73739a149cea93b42ea7a2122cec1..1a027300371fbf8e330e4b9d6d8dbfae0497eb55 100644 (file)
@@ -1724,7 +1724,6 @@ static int attach_luks_or_plain_or_bitlk_by_tpm2(
                 }
 
                 if (r == -EOPNOTSUPP) { /* Plugin not available, let's process TPM2 stuff right here instead */
-                        _cleanup_(iovec_done) struct iovec blob = {}, policy_hash = {};
                         bool found_some = false;
                         int token = 0; /* first token to look at */
 
@@ -1734,6 +1733,7 @@ static int attach_luks_or_plain_or_bitlk_by_tpm2(
 
                         for (;;) {
                                 _cleanup_(iovec_done) struct iovec pubkey = {}, salt = {}, srk = {}, pcrlock_nv = {};
+                                _cleanup_(iovec_done) struct iovec blob = {}, policy_hash = {};
                                 uint32_t hash_pcr_mask, pubkey_pcr_mask;
                                 uint16_t pcr_bank, primary_alg;
                                 TPM2Flags tpm2_flags;