Skip to content

Commit eca9fdf

Browse files
committed
Merge tag 'ecryptfs-3.18-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs
Pull eCryptfs updates from Tyler Hicks: "Minor code cleanups and a fix for when eCryptfs metadata is stored in xattrs" * tag 'ecryptfs-3.18-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs: ecryptfs: remove unneeded buggy code in ecryptfs_do_create() ecryptfs: avoid to access NULL pointer when write metadata in xattr ecryptfs: remove unnecessary break after goto ecryptfs: Remove unnecessary include of syscall.h in keystore.c fs/ecryptfs/messaging.c: remove null test before kfree ecryptfs: Drop cast Use %pd in eCryptFS
2 parents 41e46ac + 0f9e2bf commit eca9fdf

4 files changed

Lines changed: 11 additions & 23 deletions

File tree

‎fs/ecryptfs/file.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
229229
if (rc) {
230230
printk(KERN_ERR "%s: Error attempting to initialize "
231231
"the lower file for the dentry with name "
232-
"[%s]; rc = [%d]\n", __func__,
233-
ecryptfs_dentry->d_name.name, rc);
232+
"[%pd]; rc = [%d]\n", __func__,
233+
ecryptfs_dentry, rc);
234234
goto out_free;
235235
}
236236
if ((ecryptfs_inode_to_private(inode)->lower_file->f_flags & O_ACCMODE)

‎fs/ecryptfs/inode.c‎

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ static void unlock_dir(struct dentry *dir)
5353

5454
static int ecryptfs_inode_test(struct inode *inode, void *lower_inode)
5555
{
56-
if (ecryptfs_inode_to_lower(inode) == (struct inode *)lower_inode)
57-
return 1;
58-
return 0;
56+
return ecryptfs_inode_to_lower(inode) == lower_inode;
5957
}
6058

6159
static int ecryptfs_inode_set(struct inode *inode, void *opaque)
@@ -192,12 +190,6 @@ ecryptfs_do_create(struct inode *directory_inode,
192190

193191
lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry);
194192
lower_dir_dentry = lock_parent(lower_dentry);
195-
if (IS_ERR(lower_dir_dentry)) {
196-
ecryptfs_printk(KERN_ERR, "Error locking directory of "
197-
"dentry\n");
198-
inode = ERR_CAST(lower_dir_dentry);
199-
goto out;
200-
}
201193
rc = vfs_create(lower_dir_dentry->d_inode, lower_dentry, mode, true);
202194
if (rc) {
203195
printk(KERN_ERR "%s: Failure to create dentry in lower fs; "
@@ -215,7 +207,6 @@ ecryptfs_do_create(struct inode *directory_inode,
215207
fsstack_copy_inode_size(directory_inode, lower_dir_dentry->d_inode);
216208
out_lock:
217209
unlock_dir(lower_dir_dentry);
218-
out:
219210
return inode;
220211
}
221212

@@ -250,8 +241,8 @@ int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry,
250241
if (rc) {
251242
printk(KERN_ERR "%s: Error attempting to initialize "
252243
"the lower file for the dentry with name "
253-
"[%s]; rc = [%d]\n", __func__,
254-
ecryptfs_dentry->d_name.name, rc);
244+
"[%pd]; rc = [%d]\n", __func__,
245+
ecryptfs_dentry, rc);
255246
goto out;
256247
}
257248
rc = ecryptfs_write_metadata(ecryptfs_dentry, ecryptfs_inode);
@@ -313,8 +304,8 @@ static int ecryptfs_i_size_read(struct dentry *dentry, struct inode *inode)
313304
if (rc) {
314305
printk(KERN_ERR "%s: Error attempting to initialize "
315306
"the lower file for the dentry with name "
316-
"[%s]; rc = [%d]\n", __func__,
317-
dentry->d_name.name, rc);
307+
"[%pd]; rc = [%d]\n", __func__,
308+
dentry, rc);
318309
return rc;
319310
}
320311

@@ -418,8 +409,8 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
418409
if (IS_ERR(lower_dentry)) {
419410
rc = PTR_ERR(lower_dentry);
420411
ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
421-
"[%d] on lower_dentry = [%s]\n", __func__, rc,
422-
ecryptfs_dentry->d_name.name);
412+
"[%d] on lower_dentry = [%pd]\n", __func__, rc,
413+
ecryptfs_dentry);
423414
goto out;
424415
}
425416
if (lower_dentry->d_inode)
@@ -1039,7 +1030,7 @@ ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value,
10391030
}
10401031

10411032
rc = vfs_setxattr(lower_dentry, name, value, size, flags);
1042-
if (!rc)
1033+
if (!rc && dentry->d_inode)
10431034
fsstack_copy_attr_all(dentry->d_inode, lower_dentry->d_inode);
10441035
out:
10451036
return rc;

‎fs/ecryptfs/keystore.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
*/
2727

2828
#include <linux/string.h>
29-
#include <linux/syscalls.h>
3029
#include <linux/pagemap.h>
3130
#include <linux/key.h>
3231
#include <linux/random.h>
@@ -1846,7 +1845,6 @@ int ecryptfs_parse_packet_set(struct ecryptfs_crypt_stat *crypt_stat,
18461845
"(Tag 11 not allowed by itself)\n");
18471846
rc = -EIO;
18481847
goto out_wipe_list;
1849-
break;
18501848
default:
18511849
ecryptfs_printk(KERN_DEBUG, "No packet at offset [%zd] "
18521850
"of the file header; hex value of "

‎fs/ecryptfs/messaging.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,7 @@ void ecryptfs_release_messaging(void)
434434
mutex_lock(&ecryptfs_msg_ctx_lists_mux);
435435
for (i = 0; i < ecryptfs_message_buf_len; i++) {
436436
mutex_lock(&ecryptfs_msg_ctx_arr[i].mux);
437-
if (ecryptfs_msg_ctx_arr[i].msg)
438-
kfree(ecryptfs_msg_ctx_arr[i].msg);
437+
kfree(ecryptfs_msg_ctx_arr[i].msg);
439438
mutex_unlock(&ecryptfs_msg_ctx_arr[i].mux);
440439
}
441440
kfree(ecryptfs_msg_ctx_arr);

0 commit comments

Comments
 (0)