summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2017-05-17 09:49:37 -0400
committerSasha Levin <alexander.levin@verizon.com>2017-06-25 22:02:19 -0400
commit951269f95603208493aa6749c4554add9ab37372 (patch)
tree70710b449c7fe8a0bcc2bd869d643d684d21a8e3
parentd42014c8d4ce52834418402295283380b1e7c55f (diff)
btrfs: fix memory leak in update_space_info failure path
[ Upstream commit 896533a7da929136d0432713f02a3edffece2826 ] 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> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
-rw-r--r--fs/btrfs/extent-tree.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 2771bc32dbd9..1d8b3f8c3654 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3732,6 +3732,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;
}