@@ -443,10 +443,6 @@ static int setup_file_encryption_key(struct fscrypt_info *ci,
struct fscrypt_master_key *mk;
int err;
- err = fscrypt_select_encryption_impl(ci);
- if (err)
- return err;
-
err = fscrypt_policy_to_key_spec(&ci->ci_policy, &mk_spec);
if (err)
return err;
@@ -580,6 +576,10 @@ fscrypt_setup_encryption_info(struct inode *inode,
WARN_ON_ONCE(mode->ivsize > FSCRYPT_MAX_IV_SIZE);
crypt_info->ci_mode = mode;
+ res = fscrypt_select_encryption_impl(crypt_info);
+ if (res)
+ goto out;
+
res = setup_file_encryption_key(crypt_info, need_dirhash_key, &mk);
if (res)
goto out;
setup_file_encryption_key() is doing a lot of things at the moment -- setting the crypt_info's inline encryption bit, finding and locking a master key, and calling the functions to get the appropriate prepared key for this info. Since setting the inline encryption bit has nothing to do with finding the master key, it's easy and hopefully clearer to select the encryption implementation in fscrypt_setup_encryption_info(), the main fscrypt_info setup function, instead of in setup_file_encryption_key() which will long-term only deal in setting up the prepared key for the info. Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me> --- fs/crypto/keysetup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)