]> git.hungrycats.org Git - linux/commitdiff
Btrfs: fix memory leak in the extent_same ioctl
authorFilipe Manana <fdmanana@suse.com>
Fri, 3 Jul 2015 10:36:49 +0000 (11:36 +0100)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Fri, 3 Jul 2015 18:04:45 +0000 (14:04 -0400)
We were allocating memory with memdup_user() but we were never releasing
that memory. This affected pretty much every call to the ioctl, whether
it deduplicated extents or not.

This issue was reported on IRC by Julian Taylor and on the mailing list
by Marcel Ritter, credit goes to them for finding the issue.

Reported-by: Julian Taylor <jtaylor.debian@googlemail.com>
Reported-by: Marcel Ritter <ritter.marcel@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Filipe Manana <fdmanana@suse.com>
fs/btrfs/ioctl.c

index 2aa49fb7ffffc8c380419c4784c07f070ea28001..a19ba08330086f4dacf58bd617b10203486a2f0e 100644 (file)
@@ -3071,7 +3071,7 @@ out_unlock:
 static long btrfs_ioctl_file_extent_same(struct file *file,
                        struct btrfs_ioctl_same_args __user *argp)
 {
-       struct btrfs_ioctl_same_args *same;
+       struct btrfs_ioctl_same_args *same = NULL;
        struct btrfs_ioctl_same_extent_info *info;
        struct inode *src = file_inode(file);
        u64 off;
@@ -3101,6 +3101,7 @@ static long btrfs_ioctl_file_extent_same(struct file *file,
 
        if (IS_ERR(same)) {
                ret = PTR_ERR(same);
+               same = NULL;
                goto out;
        }
 
@@ -3171,6 +3172,7 @@ static long btrfs_ioctl_file_extent_same(struct file *file,
 
 out:
        mnt_drop_write_file(file);
+       kfree(same);
        return ret;
 }