ecryptfs: get rid of pointless dget/dput in ->symlink() and ->link()
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 29 Jan 2021 22:32:40 +0000 (17:32 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 8 Mar 2021 15:24:10 +0000 (10:24 -0500)
calls in ->unlink(), ->rmdir() and ->rename() make sense - we want
to prevent the underlying dentries going negative there.  In
->symlink() and ->link() they are absolutely pointless.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/ecryptfs/inode.c

index 18e9285fbb4c8dc339bd6f9b3d7472621497a31f..689aa493e58754f2e6331d6bb02c67d8389052b3 100644 (file)
@@ -437,8 +437,6 @@ static int ecryptfs_link(struct dentry *old_dentry, struct inode *dir,
        file_size_save = i_size_read(d_inode(old_dentry));
        lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry);
        lower_new_dentry = ecryptfs_dentry_to_lower(new_dentry);
-       dget(lower_old_dentry);
-       dget(lower_new_dentry);
        lower_dir_dentry = lock_parent(lower_new_dentry);
        rc = vfs_link(lower_old_dentry, &init_user_ns,
                      d_inode(lower_dir_dentry), lower_new_dentry, NULL);
@@ -454,8 +452,6 @@ static int ecryptfs_link(struct dentry *old_dentry, struct inode *dir,
        i_size_write(d_inode(new_dentry), file_size_save);
 out_lock:
        unlock_dir(lower_dir_dentry);
-       dput(lower_new_dentry);
-       dput(lower_old_dentry);
        return rc;
 }
 
@@ -476,7 +472,6 @@ static int ecryptfs_symlink(struct user_namespace *mnt_userns,
        struct ecryptfs_mount_crypt_stat *mount_crypt_stat = NULL;
 
        lower_dentry = ecryptfs_dentry_to_lower(dentry);
-       dget(lower_dentry);
        lower_dir_dentry = lock_parent(lower_dentry);
        mount_crypt_stat = &ecryptfs_superblock_to_private(
                dir->i_sb)->mount_crypt_stat;
@@ -498,7 +493,6 @@ static int ecryptfs_symlink(struct user_namespace *mnt_userns,
        fsstack_copy_inode_size(dir, d_inode(lower_dir_dentry));
 out_lock:
        unlock_dir(lower_dir_dentry);
-       dput(lower_dentry);
        if (d_really_is_negative(dentry))
                d_drop(dentry);
        return rc;