diff options
author | Jan Kara <jack@suse.cz> | 2023-07-03 16:49:11 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-07-19 16:36:59 +0200 |
commit | f5a48c015129eed88a276e09188541ad5f5d766f (patch) | |
tree | df03603b65d8c9faf9d8f9f70daa30bfbb8c92a8 /fs | |
parent | ac2d66430ea67bbcdb9fe0912ba5a68137cb8808 (diff) | |
download | linux-stable-f5a48c015129eed88a276e09188541ad5f5d766f.tar.gz linux-stable-f5a48c015129eed88a276e09188541ad5f5d766f.tar.bz2 linux-stable-f5a48c015129eed88a276e09188541ad5f5d766f.zip |
fs: no need to check source
commit 66d8fc0539b0d49941f313c9509a8384e4245ac1 upstream.
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: 28eceeda130f ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/namei.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/fs/namei.c b/fs/namei.c index 6a5e26a529e1..7e5cb92feab3 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4872,8 +4872,7 @@ int vfs_rename(struct renamedata *rd) d_exchange(old_dentry, new_dentry); } out: - if (source) - inode_unlock(source); + inode_unlock(source); if (target) inode_unlock(target); dput(new_dentry); |