From: Jeff Mahoney Date: Wed, 17 May 2017 13:49:37 +0000 (-0400) Subject: btrfs: fix memory leak in update_space_info failure path X-Git-Tag: v4.4.72~28 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5c7955c8726c1883e1577ed39d348c46a8c9bc7b;p=profile%2Fcommon%2Fplatform%2Fkernel%2Flinux-artik7.git btrfs: fix memory leak in update_space_info failure path 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 Reviewed-by: Liu Bo Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 2a2e370..c36a03f 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3854,6 +3854,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; }