diff options
| -rw-r--r-- | fs/btrfs/ioctl.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 03df0bbb445d..45a19c6b2341 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
| @@ -2680,32 +2680,31 @@ static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg) | |||
| 2680 | if (ret) | 2680 | if (ret) |
| 2681 | return ret; | 2681 | return ret; |
| 2682 | 2682 | ||
| 2683 | vol_args = memdup_user(arg, sizeof(*vol_args)); | ||
| 2684 | if (IS_ERR(vol_args)) { | ||
| 2685 | ret = PTR_ERR(vol_args); | ||
| 2686 | goto err_drop; | ||
| 2687 | } | ||
| 2688 | |||
| 2689 | vol_args->name[BTRFS_PATH_NAME_MAX] = '\0'; | ||
| 2690 | |||
| 2691 | if (atomic_xchg(&root->fs_info->mutually_exclusive_operation_running, | 2683 | if (atomic_xchg(&root->fs_info->mutually_exclusive_operation_running, |
| 2692 | 1)) { | 2684 | 1)) { |
| 2693 | ret = BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS; | 2685 | ret = BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS; |
| 2686 | goto out_drop_write; | ||
| 2687 | } | ||
| 2688 | |||
| 2689 | vol_args = memdup_user(arg, sizeof(*vol_args)); | ||
| 2690 | if (IS_ERR(vol_args)) { | ||
| 2691 | ret = PTR_ERR(vol_args); | ||
| 2694 | goto out; | 2692 | goto out; |
| 2695 | } | 2693 | } |
| 2696 | 2694 | ||
| 2695 | vol_args->name[BTRFS_PATH_NAME_MAX] = '\0'; | ||
| 2697 | mutex_lock(&root->fs_info->volume_mutex); | 2696 | mutex_lock(&root->fs_info->volume_mutex); |
| 2698 | ret = btrfs_rm_device(root, vol_args->name); | 2697 | ret = btrfs_rm_device(root, vol_args->name); |
| 2699 | mutex_unlock(&root->fs_info->volume_mutex); | 2698 | mutex_unlock(&root->fs_info->volume_mutex); |
| 2700 | atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0); | ||
| 2701 | 2699 | ||
| 2702 | if (!ret) | 2700 | if (!ret) |
| 2703 | btrfs_info(root->fs_info, "disk deleted %s",vol_args->name); | 2701 | btrfs_info(root->fs_info, "disk deleted %s",vol_args->name); |
| 2704 | |||
| 2705 | out: | ||
| 2706 | kfree(vol_args); | 2702 | kfree(vol_args); |
| 2707 | err_drop: | 2703 | out: |
| 2704 | atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0); | ||
| 2705 | out_drop_write: | ||
| 2708 | mnt_drop_write_file(file); | 2706 | mnt_drop_write_file(file); |
| 2707 | |||
| 2709 | return ret; | 2708 | return ret; |
| 2710 | } | 2709 | } |
| 2711 | 2710 | ||
