Skip to content

Commit 66d8fc0

Browse files
jankarabrauner
authored andcommitted
fs: no need to check source
The @source inode must be valid. It is even checked via IS_SWAPFILE() above making it pretty clear. So no need to check it when we unlock. What doesn't need to exist is the @target inode. The lock_two_inodes() helper currently swaps the @Inode1 and @inode2 arguments if @Inode1 is NULL to have consistent lock class usage. However, we know that at least for vfs_rename() that @Inode1 is @source and thus is never NULL as per above. We also know that @source is a different inode than @target as that is checked right at the beginning of vfs_rename(). So we know that @source is valid and locked and that @target is locked. So drop the check whether @source is non-NULL. Fixes: 28eceed ("fs: Lock moved directories") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/r/202307030026.9sE2pk2x-lkp@intel.com Message-Id: <20230703-vfs-rename-source-v1-1-37eebb29b65b@kernel.org> [brauner: use commit message from patch I sent concurrently] Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 24be4d0 commit 66d8fc0

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

fs/namei.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4874,8 +4874,7 @@ int vfs_rename(struct renamedata *rd)
48744874
d_exchange(old_dentry, new_dentry);
48754875
}
48764876
out:
4877-
if (source)
4878-
inode_unlock(source);
4877+
inode_unlock(source);
48794878
if (target)
48804879
inode_unlock(target);
48814880
dput(new_dentry);

0 commit comments

Comments
 (0)