aboutsummaryrefslogtreecommitdiffstats
path: root/fs/crypto/crypto.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-03-18 10:23:33 -0700
committerTheodore Ts'o <tytso@mit.edu>2019-04-16 18:37:25 -0400
commitcd0265fcd2eae9004c68ef2123a9dac0dc5a666a (patch)
tree3d0ecb2c81a38689f21b9f056938cbdaaf6156ed /fs/crypto/crypto.c
parentLinux 5.1-rc5 (diff)
downloadlinux-dev-cd0265fcd2eae9004c68ef2123a9dac0dc5a666a.tar.xz
linux-dev-cd0265fcd2eae9004c68ef2123a9dac0dc5a666a.zip
fscrypt: drop inode argument from fscrypt_get_ctx()
The only reason the inode is being passed to fscrypt_get_ctx() is to verify that the encryption key is available. However, all callers already ensure this because if we get as far as trying to do I/O to an encrypted file without the key, there's already a bug. Therefore, remove this unnecessary argument. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/crypto/crypto.c')
-rw-r--r--fs/crypto/crypto.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index 4dc788e3bc96..5efc494a4e38 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -87,23 +87,17 @@ EXPORT_SYMBOL(fscrypt_release_ctx);
/**
* fscrypt_get_ctx() - Gets an encryption context
- * @inode: The inode for which we are doing the crypto
* @gfp_flags: The gfp flag for memory allocation
*
* Allocates and initializes an encryption context.
*
- * Return: An allocated and initialized encryption context on success; error
- * value or NULL otherwise.
+ * Return: A new encryption context on success; an ERR_PTR() otherwise.
*/
-struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode, gfp_t gfp_flags)
+struct fscrypt_ctx *fscrypt_get_ctx(gfp_t gfp_flags)
{
- struct fscrypt_ctx *ctx = NULL;
- struct fscrypt_info *ci = inode->i_crypt_info;
+ struct fscrypt_ctx *ctx;
unsigned long flags;
- if (ci == NULL)
- return ERR_PTR(-ENOKEY);
-
/*
* We first try getting the ctx from a free list because in
* the common case the ctx will have an allocated and
@@ -258,9 +252,9 @@ struct page *fscrypt_encrypt_page(const struct inode *inode,
BUG_ON(!PageLocked(page));
- ctx = fscrypt_get_ctx(inode, gfp_flags);
+ ctx = fscrypt_get_ctx(gfp_flags);
if (IS_ERR(ctx))
- return (struct page *)ctx;
+ return ERR_CAST(ctx);
/* The encryption operation will require a bounce page. */
ciphertext_page = fscrypt_alloc_bounce_page(ctx, gfp_flags);