Skip to content

Commit 7fdeb23

Browse files
committed
Merge tag 'v6.5/vfs.fixes.2' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs fixes from Christian Brauner: "This contains two minor fixes for Jan's rename locking work: - Unlocking the source inode was guarded by a check whether source was non-NULL. This doesn't make sense because source must be non-NULL and the commit message explains in detail why - The lock_two_nondirectories() helper called WARN_ON_ONCE() and dereferenced the inodes unconditionally but the underlying lock_two_inodes() helper and the kernel documentation for that function are clear that it is valid to pass NULL arguments, so a non-NULL check is needed. No callers currently pass NULL arguments but let's not knowingly leave landmines around" * tag 'v6.5/vfs.fixes.2' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: fs: don't assume arguments are non-NULL fs: no need to check source
2 parents a452483 + 33ab231 commit 7fdeb23

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

fs/inode.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,8 +1156,10 @@ void lock_two_inodes(struct inode *inode1, struct inode *inode2,
11561156
*/
11571157
void lock_two_nondirectories(struct inode *inode1, struct inode *inode2)
11581158
{
1159-
WARN_ON_ONCE(S_ISDIR(inode1->i_mode));
1160-
WARN_ON_ONCE(S_ISDIR(inode2->i_mode));
1159+
if (inode1)
1160+
WARN_ON_ONCE(S_ISDIR(inode1->i_mode));
1161+
if (inode2)
1162+
WARN_ON_ONCE(S_ISDIR(inode2->i_mode));
11611163
lock_two_inodes(inode1, inode2, I_MUTEX_NORMAL, I_MUTEX_NONDIR2);
11621164
}
11631165
EXPORT_SYMBOL(lock_two_nondirectories);

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)