Fix resource leaks in utils_reencrypt.c

Fixes: #703.
This commit is contained in:
Ondrej Kozina
2022-01-24 14:43:42 +01:00
committed by Milan Broz
parent 71f33418d2
commit 161eeb7473

View File

@@ -659,16 +659,18 @@ static int action_reencrypt_luks2(struct crypt_device *cd, const char *data_devi
r = _check_luks2_keyslots(cd, vk_change); r = _check_luks2_keyslots(cd, vk_change);
if (r) if (r)
return r; goto out;
r = crypt_keyslot_max(CRYPT_LUKS2); r = crypt_keyslot_max(CRYPT_LUKS2);
if (r < 0) if (r < 0)
return r; goto out;
kp_size = r; kp_size = r;
kp = init_keyslot_passwords(kp_size); kp = init_keyslot_passwords(kp_size);
if (!kp) if (!kp) {
return -ENOMEM; r = -ENOMEM;
goto out;
}
r = fill_keyslot_passwords(cd, kp, kp_size, vk_change); r = fill_keyslot_passwords(cd, kp, kp_size, vk_change);
if (r) if (r)