Commit 19d00cc1 authored by Wang Cong's avatar Wang Cong Committed by Chris Mason

Btrfs: cleanup fs/btrfs/super.c::btrfs_control_ioctl()

- Remove the unused local variable 'len';
- Check return value of kmalloc().
Signed-off-by: default avatarWang Cong <wangcong@zeuux.org>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent c071fcfd
...@@ -583,17 +583,18 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd, ...@@ -583,17 +583,18 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
struct btrfs_ioctl_vol_args *vol; struct btrfs_ioctl_vol_args *vol;
struct btrfs_fs_devices *fs_devices; struct btrfs_fs_devices *fs_devices;
int ret = -ENOTTY; int ret = -ENOTTY;
int len;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
vol = kmalloc(sizeof(*vol), GFP_KERNEL); vol = kmalloc(sizeof(*vol), GFP_KERNEL);
if (!vol)
return -ENOMEM;
if (copy_from_user(vol, (void __user *)arg, sizeof(*vol))) { if (copy_from_user(vol, (void __user *)arg, sizeof(*vol))) {
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
} }
len = strnlen(vol->name, BTRFS_PATH_NAME_MAX);
switch (cmd) { switch (cmd) {
case BTRFS_IOC_SCAN_DEV: case BTRFS_IOC_SCAN_DEV:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment