Commit 80a755545d54c8e9fd801f0de3d015defd825659

Authored by Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull vfs fixes from Al Viro:
 "A couple of fixes - deadlock in CIFS and build breakage in cris serial
  driver (resurfaced f_dentry in there)"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  VFS: Convert file->f_dentry->d_inode to file_inode()
  fix deadlock in cifs_ioctl_clone()

Showing 2 changed files Side-by-side Diff

arch/cris/arch-v32/drivers/sync_serial.c
... ... @@ -604,7 +604,7 @@
604 604 struct timespec *ts)
605 605 {
606 606 unsigned long flags;
607   - int dev = MINOR(file->f_dentry->d_inode->i_rdev);
  607 + int dev = MINOR(file_inode(file)->i_rdev);
608 608 int avail;
609 609 struct sync_port *port;
610 610 unsigned char *start;
... ... @@ -86,22 +86,17 @@
86 86 }
87 87  
88 88 src_inode = file_inode(src_file.file);
  89 + rc = -EINVAL;
  90 + if (S_ISDIR(src_inode->i_mode))
  91 + goto out_fput;
89 92  
90 93 /*
91 94 * Note: cifs case is easier than btrfs since server responsible for
92 95 * checks for proper open modes and file type and if it wants
93 96 * server could even support copy of range where source = target
94 97 */
  98 + lock_two_nondirectories(target_inode, src_inode);
95 99  
96   - /* so we do not deadlock racing two ioctls on same files */
97   - if (target_inode < src_inode) {
98   - mutex_lock_nested(&target_inode->i_mutex, I_MUTEX_PARENT);
99   - mutex_lock_nested(&src_inode->i_mutex, I_MUTEX_CHILD);
100   - } else {
101   - mutex_lock_nested(&src_inode->i_mutex, I_MUTEX_PARENT);
102   - mutex_lock_nested(&target_inode->i_mutex, I_MUTEX_CHILD);
103   - }
104   -
105 100 /* determine range to clone */
106 101 rc = -EINVAL;
107 102 if (off + len > src_inode->i_size || off + len < off)
... ... @@ -124,13 +119,7 @@
124 119 out_unlock:
125 120 /* although unlocking in the reverse order from locking is not
126 121 strictly necessary here it is a little cleaner to be consistent */
127   - if (target_inode < src_inode) {
128   - mutex_unlock(&src_inode->i_mutex);
129   - mutex_unlock(&target_inode->i_mutex);
130   - } else {
131   - mutex_unlock(&target_inode->i_mutex);
132   - mutex_unlock(&src_inode->i_mutex);
133   - }
  122 + unlock_two_nondirectories(src_inode, target_inode);
134 123 out_fput:
135 124 fdput(src_file);
136 125 out_drop_write: