]> 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@serenity.furryterror.org>
Fri, 3 Jul 2015 18:05:28 +0000 (14:05 -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 5fdad2162e2284712e793741384cb14285b148c7..7cef9c8956aecf1a7296e62accb0efb23aa4dcc6 100644 (file)
@@ -3078,7 +3078,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;
@@ -3108,6 +3108,7 @@ static long btrfs_ioctl_file_extent_same(struct file *file,
 
        if (IS_ERR(same)) {
                ret = PTR_ERR(same);
+               same = NULL;
                goto out;
        }
 
@@ -3178,6 +3179,7 @@ static long btrfs_ioctl_file_extent_same(struct file *file,
 
 out:
        mnt_drop_write_file(file);
+       kfree(same);
        return ret;
 }