]> git.hungrycats.org Git - linux/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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jun 2017 13:07:46 +0000 (15:07 +0200)
commit 896533a7da929136d0432713f02a3edffece2826 upstream.

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)
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/extent-tree.c

index be5477676cc829e4efe89349fc9b7df540fd0dff..2f23fd4a08f1d931d8993af948e31b0d68245ce4 100644 (file)
@@ -3983,6 +3983,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;
        }