]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
Btrfs: don't leak ioctl args in btrfs_ioctl_dev_replace
authorIlya Dryomov <idryomov@gmail.com>
Thu, 10 Oct 2013 17:39:28 +0000 (20:39 +0300)
committerChris Mason <chris.mason@fusionio.com>
Tue, 12 Nov 2013 03:00:37 +0000 (22:00 -0500)
struct btrfs_ioctl_dev_replace_args memory is leaked if replace is
requested on a read-only filesystem.  Fix it.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
fs/btrfs/ioctl.c

index 98d4ffef961e8baaa6e2c7ade5e2a0a0ce8a274e..08ac53c5f78d7402bed71fbd25f99a31d55f5082 100644 (file)
@@ -3667,9 +3667,10 @@ static long btrfs_ioctl_dev_replace(struct btrfs_root *root, void __user *arg)
 
        switch (p->cmd) {
        case BTRFS_IOCTL_DEV_REPLACE_CMD_START:
-               if (root->fs_info->sb->s_flags & MS_RDONLY)
-                       return -EROFS;
-
+               if (root->fs_info->sb->s_flags & MS_RDONLY) {
+                       ret = -EROFS;
+                       goto out;
+               }
                if (atomic_xchg(
                        &root->fs_info->mutually_exclusive_operation_running,
                        1)) {
@@ -3695,7 +3696,7 @@ static long btrfs_ioctl_dev_replace(struct btrfs_root *root, void __user *arg)
 
        if (copy_to_user(arg, p, sizeof(*p)))
                ret = -EFAULT;
-
+out:
        kfree(p);
        return ret;
 }