Skip to content

Commit 2355ac8

Browse files
committed
btrfs: ioctl: reorder exclusive op check in RM_DEV
Move the op exclusivity check before the other code (same as in ADD_DEV). Signed-off-by: David Sterba <[email protected]>
1 parent 58409ed commit 2355ac8

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

fs/btrfs/ioctl.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2680,32 +2680,31 @@ static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg)
26802680
if (ret)
26812681
return ret;
26822682

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-
26912683
if (atomic_xchg(&root->fs_info->mutually_exclusive_operation_running,
26922684
1)) {
26932685
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);
26942692
goto out;
26952693
}
26962694

2695+
vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
26972696
mutex_lock(&root->fs_info->volume_mutex);
26982697
ret = btrfs_rm_device(root, vol_args->name);
26992698
mutex_unlock(&root->fs_info->volume_mutex);
2700-
atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0);
27012699

27022700
if (!ret)
27032701
btrfs_info(root->fs_info, "disk deleted %s",vol_args->name);
2704-
2705-
out:
27062702
kfree(vol_args);
2707-
err_drop:
2703+
out:
2704+
atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0);
2705+
out_drop_write:
27082706
mnt_drop_write_file(file);
2707+
27092708
return ret;
27102709
}
27112710

0 commit comments

Comments
 (0)