]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cryptsetup: Fix misplaced assert.
authorOndrej Kozina <okozina@redhat.com>
Mon, 31 May 2021 17:08:14 +0000 (19:08 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 7 Jun 2021 20:40:32 +0000 (22:40 +0200)
Seems the assert should be placed in-before decrypted_key
pointer is passed to libcryptsetup API.

Original placement would trigger abort in case tpm2
hw was not present in the system while required
to activate crypt devices.

src/cryptsetup/cryptsetup.c

index dd84018c1743435152871338dcff78bd3ae78dce..287069766c7a6acd6e9cf5a5a503afab764b475f 100644 (file)
@@ -1140,7 +1140,6 @@ static int attach_luks_or_plain_or_bitlk_by_tpm2(
                         if (r != -EAGAIN) /* EAGAIN means: no tpm2 chip found */
                                 return r;
                 }
-                assert(decrypted_key);
 
                 if (!monitor) {
                         /* We didn't find the TPM2 device. In this case, watch for it via udev. Let's create
@@ -1181,6 +1180,7 @@ static int attach_luks_or_plain_or_bitlk_by_tpm2(
 
                 log_debug("Got one or more potentially relevant udev events, rescanning for TPM2...");
         }
+        assert(decrypted_key);
 
         if (pass_volume_key)
                 r = crypt_activate_by_volume_key(cd, name, decrypted_key, decrypted_key_size, flags);