diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c index a4e01a6fcc00..0fdab9f491b4 100644 --- a/fs/crypto/keysetup.c +++ b/fs/crypto/keysetup.c @@ -477,18 +477,9 @@ static void put_crypt_info(struct fscrypt_info *ci) if (ci->ci_direct_key) fscrypt_put_direct_key(ci->ci_direct_key); - else if (ci->ci_owns_key) { - if (fscrypt_policy_contents_mode(&ci->ci_policy) != - FSCRYPT_MODE_PRIVATE) { - fscrypt_destroy_prepared_key(&ci->ci_key); - } else { - crypto_free_skcipher(ci->ci_key.tfm); -#ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT - if (ci->ci_key.blk_key) - kzfree(ci->ci_key.blk_key); -#endif - } - } + else if (ci->ci_owns_key) + fscrypt_destroy_prepared_key(&ci->ci_key); + key = ci->ci_master_key; if (key) { struct fscrypt_master_key *mk = key->payload.data[0]; diff --git a/fs/crypto/keysetup_v1.c b/fs/crypto/keysetup_v1.c index 0dc04c55ad55..e67fec7df434 100644 --- a/fs/crypto/keysetup_v1.c +++ b/fs/crypto/keysetup_v1.c @@ -314,7 +314,6 @@ static int setup_v1_file_key_derived(struct fscrypt_info *ci, if ((fscrypt_policy_contents_mode(&ci->ci_policy) == FSCRYPT_MODE_PRIVATE) && fscrypt_using_inline_encryption(ci)) { - ci->ci_owns_key = true; if (ci->ci_policy.v1.flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32) { union { @@ -353,11 +352,8 @@ static int setup_v1_file_key_derived(struct fscrypt_info *ci, for (i = 0; i < ARRAY_SIZE(key_new.words); i++) __cpu_to_be32s(&key_new.words[i]); - err = fscrypt_prepare_inline_crypt_key(&ci->ci_key, - key_new.bytes, - ci->ci_mode->keysize, - false, - ci); + err = setup_v1_file_key_direct(ci, key_new.bytes); + if (derived_key) kzfree(derived_key);