diff options
| -rw-r--r-- | fs/crypto/bio.c | 2 | ||||
| -rw-r--r-- | fs/crypto/crypto.c | 16 | ||||
| -rw-r--r-- | fs/ext4/readpage.c | 2 | ||||
| -rw-r--r-- | include/linux/fscrypt.h | 5 |
4 files changed, 9 insertions, 16 deletions
diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c index 5759bcd018cd..f5b69b9531f6 100644 --- a/fs/crypto/bio.c +++ b/fs/crypto/bio.c | |||
| @@ -104,7 +104,7 @@ int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk, | |||
| 104 | 104 | ||
| 105 | BUG_ON(inode->i_sb->s_blocksize != PAGE_SIZE); | 105 | BUG_ON(inode->i_sb->s_blocksize != PAGE_SIZE); |
| 106 | 106 | ||
| 107 | ctx = fscrypt_get_ctx(inode, GFP_NOFS); | 107 | ctx = fscrypt_get_ctx(GFP_NOFS); |
| 108 | if (IS_ERR(ctx)) | 108 | if (IS_ERR(ctx)) |
| 109 | return PTR_ERR(ctx); | 109 | return PTR_ERR(ctx); |
| 110 | 110 | ||
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); | |||
| 87 | 87 | ||
| 88 | /** | 88 | /** |
| 89 | * fscrypt_get_ctx() - Gets an encryption context | 89 | * fscrypt_get_ctx() - Gets an encryption context |
| 90 | * @inode: The inode for which we are doing the crypto | ||
| 91 | * @gfp_flags: The gfp flag for memory allocation | 90 | * @gfp_flags: The gfp flag for memory allocation |
| 92 | * | 91 | * |
| 93 | * Allocates and initializes an encryption context. | 92 | * Allocates and initializes an encryption context. |
| 94 | * | 93 | * |
| 95 | * Return: An allocated and initialized encryption context on success; error | 94 | * Return: A new encryption context on success; an ERR_PTR() otherwise. |
| 96 | * value or NULL otherwise. | ||
| 97 | */ | 95 | */ |
| 98 | struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode, gfp_t gfp_flags) | 96 | struct fscrypt_ctx *fscrypt_get_ctx(gfp_t gfp_flags) |
| 99 | { | 97 | { |
| 100 | struct fscrypt_ctx *ctx = NULL; | 98 | struct fscrypt_ctx *ctx; |
| 101 | struct fscrypt_info *ci = inode->i_crypt_info; | ||
| 102 | unsigned long flags; | 99 | unsigned long flags; |
| 103 | 100 | ||
| 104 | if (ci == NULL) | ||
| 105 | return ERR_PTR(-ENOKEY); | ||
| 106 | |||
| 107 | /* | 101 | /* |
| 108 | * We first try getting the ctx from a free list because in | 102 | * We first try getting the ctx from a free list because in |
| 109 | * the common case the ctx will have an allocated and | 103 | * the common case the ctx will have an allocated and |
| @@ -258,9 +252,9 @@ struct page *fscrypt_encrypt_page(const struct inode *inode, | |||
| 258 | 252 | ||
| 259 | BUG_ON(!PageLocked(page)); | 253 | BUG_ON(!PageLocked(page)); |
| 260 | 254 | ||
| 261 | ctx = fscrypt_get_ctx(inode, gfp_flags); | 255 | ctx = fscrypt_get_ctx(gfp_flags); |
| 262 | if (IS_ERR(ctx)) | 256 | if (IS_ERR(ctx)) |
| 263 | return (struct page *)ctx; | 257 | return ERR_CAST(ctx); |
| 264 | 258 | ||
| 265 | /* The encryption operation will require a bounce page. */ | 259 | /* The encryption operation will require a bounce page. */ |
| 266 | ciphertext_page = fscrypt_alloc_bounce_page(ctx, gfp_flags); | 260 | ciphertext_page = fscrypt_alloc_bounce_page(ctx, gfp_flags); |
diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c index 3adadf461825..75cef6af6080 100644 --- a/fs/ext4/readpage.c +++ b/fs/ext4/readpage.c | |||
| @@ -244,7 +244,7 @@ int ext4_mpage_readpages(struct address_space *mapping, | |||
| 244 | struct fscrypt_ctx *ctx = NULL; | 244 | struct fscrypt_ctx *ctx = NULL; |
| 245 | 245 | ||
| 246 | if (IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode)) { | 246 | if (IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode)) { |
| 247 | ctx = fscrypt_get_ctx(inode, GFP_NOFS); | 247 | ctx = fscrypt_get_ctx(GFP_NOFS); |
| 248 | if (IS_ERR(ctx)) | 248 | if (IS_ERR(ctx)) |
| 249 | goto set_error_page; | 249 | goto set_error_page; |
| 250 | } | 250 | } |
diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h index e5194fc3983e..6cf8a34523ff 100644 --- a/include/linux/fscrypt.h +++ b/include/linux/fscrypt.h | |||
| @@ -90,7 +90,7 @@ static inline bool fscrypt_dummy_context_enabled(struct inode *inode) | |||
| 90 | 90 | ||
| 91 | /* crypto.c */ | 91 | /* crypto.c */ |
| 92 | extern void fscrypt_enqueue_decrypt_work(struct work_struct *); | 92 | extern void fscrypt_enqueue_decrypt_work(struct work_struct *); |
| 93 | extern struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *, gfp_t); | 93 | extern struct fscrypt_ctx *fscrypt_get_ctx(gfp_t); |
| 94 | extern void fscrypt_release_ctx(struct fscrypt_ctx *); | 94 | extern void fscrypt_release_ctx(struct fscrypt_ctx *); |
| 95 | extern struct page *fscrypt_encrypt_page(const struct inode *, struct page *, | 95 | extern struct page *fscrypt_encrypt_page(const struct inode *, struct page *, |
| 96 | unsigned int, unsigned int, | 96 | unsigned int, unsigned int, |
| @@ -247,8 +247,7 @@ static inline void fscrypt_enqueue_decrypt_work(struct work_struct *work) | |||
| 247 | { | 247 | { |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | static inline struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode, | 250 | static inline struct fscrypt_ctx *fscrypt_get_ctx(gfp_t gfp_flags) |
| 251 | gfp_t gfp_flags) | ||
| 252 | { | 251 | { |
| 253 | return ERR_PTR(-EOPNOTSUPP); | 252 | return ERR_PTR(-EOPNOTSUPP); |
| 254 | } | 253 | } |
