Fix init for util_wipe call.

It should init crypt, as it uses RNG.

Also it should fail early if no device is initialized.
This commit is contained in:
Milan Broz
2022-05-05 13:57:56 +02:00
parent 251eb37c4a
commit 227fdb7393

View File

@@ -282,6 +282,10 @@ int crypt_wipe(struct crypt_device *cd,
if (!cd)
return -EINVAL;
r = init_crypto(cd);
if (r < 0)
return r;
if (!dev_path)
device = crypt_data_device(cd);
else {
@@ -292,6 +296,8 @@ int crypt_wipe(struct crypt_device *cd,
if (flags & CRYPT_WIPE_NO_DIRECT_IO)
device_disable_direct_io(device);
}
if (!device)
return -EINVAL;
if (!wipe_block_size)
wipe_block_size = 1024*1024;