Fix memory leaks detected in compat-test-opal.

This commit is contained in:
Ondrej Kozina
2023-11-06 16:40:57 +01:00
parent 2a9752b6c8
commit 860550b3c6
2 changed files with 8 additions and 5 deletions

View File

@@ -471,6 +471,8 @@ int opal_setup_ranges(struct crypt_device *cd,
}
}
crypt_safe_free(user_session);
user_session = crypt_safe_alloc(sizeof(struct opal_session_info));
if (!user_session) {
r = -ENOMEM;

View File

@@ -2896,14 +2896,15 @@ static int opal_erase(struct crypt_device *cd, bool factory_reset) {
if (factory_reset && !ARG_SET(OPT_BATCH_MODE_ID) &&
!yesDialog(_("WARNING: WHOLE disk will be factory reset and all data will be lost! Continue?"),
_("Operation aborted.\n"))) {
crypt_safe_free(password);
return -EPERM;
}
return crypt_wipe_hw_opal(cd,
factory_reset ? CRYPT_NO_SEGMENT : CRYPT_LUKS2_SEGMENT,
password,
password_size,
0);
r = crypt_wipe_hw_opal(cd, factory_reset ? CRYPT_NO_SEGMENT : CRYPT_LUKS2_SEGMENT,
password, password_size, 0);
crypt_safe_free(password);
return r;
}
static int action_luksErase(void)