aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2017-04-04 17:39:41 -0400
committerTheodore Ts'o <tytso@mit.edu>2017-04-30 01:26:34 -0400
commitcd39e4bac11125bc32ba6101b1ceb46ef773f4b6 (patch)
tree11f17b3e501c7bf09dee2fcc06ea38751e7fa7f3
parent39da7c509acff13fc8cb12ec1bb20337c988ed36 (diff)
fscrypt: remove unnecessary checks for NULL operations
The functions in fs/crypto/*.c are only called by filesystems configured with encryption support. Since the ->get_context(), ->set_context(), and ->empty_dir() operations are always provided in that case (and must be, otherwise there would be no way to get/set encryption policies, or in the case of ->get_context() even access encrypted files at all), there is no need to check for these operations being NULL and we can remove these unneeded checks. Signed-off-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Richard Weinberger <richard@nod.at> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--fs/crypto/keyinfo.c3
-rw-r--r--fs/crypto/policy.c11
2 files changed, 1 insertions, 13 deletions
diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
index 8cdfddce2b34..179e578b875b 100644
--- a/fs/crypto/keyinfo.c
+++ b/fs/crypto/keyinfo.c
@@ -183,9 +183,6 @@ int fscrypt_get_encryption_info(struct inode *inode)
183 if (res) 183 if (res)
184 return res; 184 return res;
185 185
186 if (!inode->i_sb->s_cop->get_context)
187 return -EOPNOTSUPP;
188
189 res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx)); 186 res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
190 if (res < 0) { 187 if (res < 0) {
191 if (!fscrypt_dummy_context_enabled(inode) || 188 if (!fscrypt_dummy_context_enabled(inode) ||
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index 4908906d54d5..d71ec3780d0c 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -34,9 +34,6 @@ static int create_encryption_context_from_policy(struct inode *inode,
34{ 34{
35 struct fscrypt_context ctx; 35 struct fscrypt_context ctx;
36 36
37 if (!inode->i_sb->s_cop->set_context)
38 return -EOPNOTSUPP;
39
40 ctx.format = FS_ENCRYPTION_CONTEXT_FORMAT_V1; 37 ctx.format = FS_ENCRYPTION_CONTEXT_FORMAT_V1;
41 memcpy(ctx.master_key_descriptor, policy->master_key_descriptor, 38 memcpy(ctx.master_key_descriptor, policy->master_key_descriptor,
42 FS_KEY_DESCRIPTOR_SIZE); 39 FS_KEY_DESCRIPTOR_SIZE);
@@ -87,8 +84,6 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
87 if (ret == -ENODATA) { 84 if (ret == -ENODATA) {
88 if (!S_ISDIR(inode->i_mode)) 85 if (!S_ISDIR(inode->i_mode))
89 ret = -ENOTDIR; 86 ret = -ENOTDIR;
90 else if (!inode->i_sb->s_cop->empty_dir)
91 ret = -EOPNOTSUPP;
92 else if (!inode->i_sb->s_cop->empty_dir(inode)) 87 else if (!inode->i_sb->s_cop->empty_dir(inode))
93 ret = -ENOTEMPTY; 88 ret = -ENOTEMPTY;
94 else 89 else
@@ -118,8 +113,7 @@ int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
118 struct fscrypt_policy policy; 113 struct fscrypt_policy policy;
119 int res; 114 int res;
120 115
121 if (!inode->i_sb->s_cop->get_context || 116 if (!inode->i_sb->s_cop->is_encrypted(inode))
122 !inode->i_sb->s_cop->is_encrypted(inode))
123 return -ENODATA; 117 return -ENODATA;
124 118
125 res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx)); 119 res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
@@ -202,9 +196,6 @@ int fscrypt_inherit_context(struct inode *parent, struct inode *child,
202 struct fscrypt_info *ci; 196 struct fscrypt_info *ci;
203 int res; 197 int res;
204 198
205 if (!parent->i_sb->s_cop->set_context)
206 return -EOPNOTSUPP;
207
208 res = fscrypt_get_encryption_info(parent); 199 res = fscrypt_get_encryption_info(parent);
209 if (res < 0) 200 if (res < 0)
210 return res; 201 return res;