Skip to content

Commit

Permalink
btrfs: fix error pointer dereference in btrfs_ioctl_rm_dev_v2()
Browse files Browse the repository at this point in the history
If memdup_user() fails the error handing will crash when it tries
to kfree() an error pointer.  Just return directly because there is
no cleanup required.

Fixes: 1a15eb7 ("btrfs: use btrfs_get_dev_args_from_path in dev removal ioctls")
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Dan Carpenter authored and David Sterba committed Dec 8, 2021
1 parent daf87e9 commit d815b3f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3188,10 +3188,8 @@ static long btrfs_ioctl_rm_dev_v2(struct file *file, void __user *arg)
return -EPERM;

vol_args = memdup_user(arg, sizeof(*vol_args));
if (IS_ERR(vol_args)) {
ret = PTR_ERR(vol_args);
goto out;
}
if (IS_ERR(vol_args))
return PTR_ERR(vol_args);

if (vol_args->flags & ~BTRFS_DEVICE_REMOVE_ARGS_MASK) {
ret = -EOPNOTSUPP;
Expand Down

0 comments on commit d815b3f

Please sign in to comment.