]> 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)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Fri, 28 Jul 2017 18:19:58 +0000 (14:19 -0400)
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>
(cherry picked from commit 66d6448475c682099e4dd3c6b4ef6e94248c0b2e)

fs/btrfs/extent-tree.c

index 6d7e405678dacab127930a1d276efc0e033ddcb0..19dced456d75b0c1aa76af008323088bc289a5a6 100644 (file)
@@ -3918,6 +3918,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;
        }