diff options
Diffstat (limited to 'fs/btrfs/super.c')
| -rw-r--r-- | fs/btrfs/super.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 9744af9d71e9..a7acfe639a44 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
| @@ -635,14 +635,9 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd, | |||
| 635 | if (!capable(CAP_SYS_ADMIN)) | 635 | if (!capable(CAP_SYS_ADMIN)) |
| 636 | return -EPERM; | 636 | return -EPERM; |
| 637 | 637 | ||
| 638 | vol = kmalloc(sizeof(*vol), GFP_KERNEL); | 638 | vol = memdup_user((void __user *)arg, sizeof(*vol)); |
| 639 | if (!vol) | 639 | if (IS_ERR(vol)) |
| 640 | return -ENOMEM; | 640 | return PTR_ERR(vol); |
| 641 | |||
| 642 | if (copy_from_user(vol, (void __user *)arg, sizeof(*vol))) { | ||
| 643 | ret = -EFAULT; | ||
| 644 | goto out; | ||
| 645 | } | ||
| 646 | 641 | ||
| 647 | switch (cmd) { | 642 | switch (cmd) { |
| 648 | case BTRFS_IOC_SCAN_DEV: | 643 | case BTRFS_IOC_SCAN_DEV: |
| @@ -650,7 +645,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd, | |||
| 650 | &btrfs_fs_type, &fs_devices); | 645 | &btrfs_fs_type, &fs_devices); |
| 651 | break; | 646 | break; |
| 652 | } | 647 | } |
| 653 | out: | 648 | |
| 654 | kfree(vol); | 649 | kfree(vol); |
| 655 | return ret; | 650 | return ret; |
| 656 | } | 651 | } |
