Преглед изворни кода

Btrfs: Fix a crash when mounting a subvolume

We should drop dentry before deactivating the superblock, otherwise
we can hit this bug:

BUG: Dentry f349a690{i=100,n=/} still in use (1) [unmount of btrfs loop1]
...

Steps to reproduce the bug:

  # mount /dev/loop1 /mnt
  # mkdir save
  # btrfs subvolume snapshot /mnt save/snap1
  # umount /mnt
  # mount -o subvol=save/snap1 /dev/loop1 /mnt
  (crash)

Reported-by: Michael Niederle <mniederle@gmx.at>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Li Zefan пре 14 година
родитељ
комит
f106e82caa
1 измењених фајлова са 1 додато и 1 уклоњено
  1. 1 1
      fs/btrfs/super.c

+ 1 - 1
fs/btrfs/super.c

@@ -685,9 +685,9 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
 		mutex_unlock(&root->d_inode->i_mutex);
 		mutex_unlock(&root->d_inode->i_mutex);
 
 
 		if (IS_ERR(new_root)) {
 		if (IS_ERR(new_root)) {
+			dput(root);
 			deactivate_locked_super(s);
 			deactivate_locked_super(s);
 			error = PTR_ERR(new_root);
 			error = PTR_ERR(new_root);
-			dput(root);
 			goto error_free_subvol_name;
 			goto error_free_subvol_name;
 		}
 		}
 		if (!new_root->d_inode) {
 		if (!new_root->d_inode) {