]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
btrfs: fix memory leak in update_space_info failure path
authorJeff Mahoney <jeffm@suse.com>
Wed, 17 May 2017 13:49:37 +0000 (09:49 -0400)
committerDavid Sterba <dsterba@suse.com>
Thu, 1 Jun 2017 14:56:31 +0000 (16:56 +0200)
If we fail to add the space_info kobject, we'll leak the memory
for the percpu counter.

Fixes: 6ab0a2029c (btrfs: publish allocation data in sysfs)
Cc: <stable@vger.kernel.org> # v3.14+
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c

index e390451c72e6cdb93492e519cea82d5d7b3dfaf9..27ca5b81ed22051e771d65d4d74967d874ad7004 100644 (file)
@@ -3993,6 +3993,7 @@ static int update_space_info(struct btrfs_fs_info *info, u64 flags,
                                    info->space_info_kobj, "%s",
                                    alloc_name(found->flags));
        if (ret) {
+               percpu_counter_destroy(&found->total_bytes_pinned);
                kfree(found);
                return ret;
        }