diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-04-08 09:06:54 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-04-21 05:02:50 +0200 |
commit | dae7b665cf6d6e6e733f1c9c16cf55547dd37e33 (patch) | |
tree | ab7f9fc54bcf735c7f331f78858ec0db7f634cdd /fs/btrfs/super.c | |
parent | xattr: use memdup_user() (diff) | |
download | linux-dae7b665cf6d6e6e733f1c9c16cf55547dd37e33.tar.xz linux-dae7b665cf6d6e6e733f1c9c16cf55547dd37e33.zip |
btrfs: use memdup_user()
Remove open-coded memdup_user().
Note this changes some GFP_NOFS to GFP_KERNEL, since copy_from_user() may
cause pagefault, it's pointless to pass GFP_NOFS to kmalloc().
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
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, if (!capable(CAP_SYS_ADMIN)) return -EPERM; - vol = kmalloc(sizeof(*vol), GFP_KERNEL); - if (!vol) - return -ENOMEM; - - if (copy_from_user(vol, (void __user *)arg, sizeof(*vol))) { - ret = -EFAULT; - goto out; - } + vol = memdup_user((void __user *)arg, sizeof(*vol)); + if (IS_ERR(vol)) + return PTR_ERR(vol); switch (cmd) { case BTRFS_IOC_SCAN_DEV: @@ -650,7 +645,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd, &btrfs_fs_type, &fs_devices); break; } -out: + kfree(vol); return ret; } |