]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tpm2: fix nits from PR #26185
authorWilliam Roberts <william.c.roberts@intel.com>
Tue, 4 Apr 2023 16:14:17 +0000 (11:14 -0500)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 4 Apr 2023 19:41:11 +0000 (20:41 +0100)
Fixes:
  - Comment style
  - Alignment style
  - cleanup macro usage
  - incorrect error message[1]

1. Thanks to tempusfugit991@gmail.com for pointing out the error
message mistake.

Signed-off-by: William Roberts <william.c.roberts@intel.com>
src/cryptenroll/cryptenroll-tpm2.c
src/shared/creds-util.c
src/shared/tpm2-util.c

index 0f21ad6adff68214c29e0f6142b545cf0aab49c6..4dc3c1794d89a5d2d01a45032fe5a734089c030c 100644 (file)
@@ -142,7 +142,7 @@ int enroll_tpm2(struct crypt_device *cd,
         _cleanup_(erase_and_freep) void *secret = NULL;
         _cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *signature_json = NULL;
         _cleanup_(erase_and_freep) char *base64_encoded = NULL;
-        _cleanup_(freep) void *srk_buf = NULL;
+        _cleanup_free_ void *srk_buf = NULL;
         size_t secret_size, blob_size, hash_size, pubkey_size = 0, srk_buf_size = 0;
         _cleanup_free_ void *blob = NULL, *hash = NULL, *pubkey = NULL;
         uint16_t pcr_bank, primary_alg;
index ea3a434f8f82c497965bc45b68423ecee3f5824d..d570f49e7b51619b8dc5f39751b99c489c52d61c 100644 (file)
@@ -1035,10 +1035,8 @@ int decrypt_credential_and_warn(
                                     le32toh(z->size));
                 }
 
-                /*
-                 * TODO: Add the SRK data to the credential structure so it can be plumbed
-                 * through and used to verify the TPM session.
-                 */
+                 // TODO: Add the SRK data to the credential structure so it can be plumbed
+                 // through and used to verify the TPM session.
                 r = tpm2_unseal(tpm2_device,
                                 le64toh(t->pcr_mask),
                                 le16toh(t->pcr_bank),
index 4f51682e8d019cd40a3e64bf1cc5288f44d3e193..1ffd78c7414597a748530914857406eae8a1e202 100644 (file)
@@ -558,7 +558,7 @@ static int tpm2_make_primary(
         if (use_srk_model) {
                 r = make_lock_file("/run/systemd/tpm2-srk-init", LOCK_EX, &srk_lock);
                 if (r < 0)
-                        return log_error_errno(r, "Failed to take network zone lock: %m");
+                        return log_error_errno(r, "Failed to take TPM SRK lock: %m");
         }
 
         /* Find existing SRK and use it if present */
@@ -573,7 +573,7 @@ static int tpm2_make_primary(
 
                         if (alg != 0 && alg != got_alg)
                                 log_warning("Caller asked for specific algorithm %u, but existing SRK is %u, ignoring",
-                                                alg, got_alg);
+                                            alg, got_alg);
 
                         if (ret_alg)
                                 *ret_alg = alg;