v6.5/vfs.fixes.2

-----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCZKaBygAKCRCRxhvAZXjc
 ogwpAQC1lbyCAxmAoCa1ywELgqJnFSn8eWE63eC8lnnWw2zkBQEAyfQs1dCEc4E9
 Msf6muEBVg04OrA85czP4bw3KGzd7gQ=
 =JR2S
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2023-07-06 19:01:38 -07:00
commit 7fdeb23f32
2 changed files with 5 additions and 4 deletions

View file

@ -1156,8 +1156,10 @@ void lock_two_inodes(struct inode *inode1, struct inode *inode2,
*/
void lock_two_nondirectories(struct inode *inode1, struct inode *inode2)
{
WARN_ON_ONCE(S_ISDIR(inode1->i_mode));
WARN_ON_ONCE(S_ISDIR(inode2->i_mode));
if (inode1)
WARN_ON_ONCE(S_ISDIR(inode1->i_mode));
if (inode2)
WARN_ON_ONCE(S_ISDIR(inode2->i_mode));
lock_two_inodes(inode1, inode2, I_MUTEX_NORMAL, I_MUTEX_NONDIR2);
}
EXPORT_SYMBOL(lock_two_nondirectories);

View file

@ -4874,8 +4874,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);