aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index ac37040e426a..b793d112d1f6 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2054,29 +2054,34 @@ static long btrfs_ioctl_rm_dev(struct btrfs_root *root, void __user *arg)
2054 2054
2055static long btrfs_ioctl_fs_info(struct btrfs_root *root, void __user *arg) 2055static long btrfs_ioctl_fs_info(struct btrfs_root *root, void __user *arg)
2056{ 2056{
2057 struct btrfs_ioctl_fs_info_args fi_args; 2057 struct btrfs_ioctl_fs_info_args *fi_args;
2058 struct btrfs_device *device; 2058 struct btrfs_device *device;
2059 struct btrfs_device *next; 2059 struct btrfs_device *next;
2060 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; 2060 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices;
2061 int ret = 0;
2061 2062
2062 if (!capable(CAP_SYS_ADMIN)) 2063 if (!capable(CAP_SYS_ADMIN))
2063 return -EPERM; 2064 return -EPERM;
2064 2065
2065 fi_args.num_devices = fs_devices->num_devices; 2066 fi_args = kzalloc(sizeof(*fi_args), GFP_KERNEL);
2066 fi_args.max_id = 0; 2067 if (!fi_args)
2067 memcpy(&fi_args.fsid, root->fs_info->fsid, sizeof(fi_args.fsid)); 2068 return -ENOMEM;
2069
2070 fi_args->num_devices = fs_devices->num_devices;
2071 memcpy(&fi_args->fsid, root->fs_info->fsid, sizeof(fi_args->fsid));
2068 2072
2069 mutex_lock(&fs_devices->device_list_mutex); 2073 mutex_lock(&fs_devices->device_list_mutex);
2070 list_for_each_entry_safe(device, next, &fs_devices->devices, dev_list) { 2074 list_for_each_entry_safe(device, next, &fs_devices->devices, dev_list) {
2071 if (device->devid > fi_args.max_id) 2075 if (device->devid > fi_args->max_id)
2072 fi_args.max_id = device->devid; 2076 fi_args->max_id = device->devid;
2073 } 2077 }
2074 mutex_unlock(&fs_devices->device_list_mutex); 2078 mutex_unlock(&fs_devices->device_list_mutex);
2075 2079
2076 if (copy_to_user(arg, &fi_args, sizeof(fi_args))) 2080 if (copy_to_user(arg, fi_args, sizeof(*fi_args)))
2077 return -EFAULT; 2081 ret = -EFAULT;
2078 2082
2079 return 0; 2083 kfree(fi_args);
2084 return ret;
2080} 2085}
2081 2086
2082static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg) 2087static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg)