Commit 951269f9 authored by Jeff Mahoney's avatar Jeff Mahoney Committed by Sasha Levin

btrfs: fix memory leak in update_space_info failure path

[ Upstream commit 896533a7 ]

If we fail to add the space_info kobject, we'll leak the memory
for the percpu counter.

Fixes: 6ab0a202 (btrfs: publish allocation data in sysfs)
Cc: <stable@vger.kernel.org> # v3.14+
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Reviewed-by: default avatarLiu Bo <bo.li.liu@oracle.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
parent d42014c8
...@@ -3732,6 +3732,7 @@ static int update_space_info(struct btrfs_fs_info *info, u64 flags, ...@@ -3732,6 +3732,7 @@ static int update_space_info(struct btrfs_fs_info *info, u64 flags,
info->space_info_kobj, "%s", info->space_info_kobj, "%s",
alloc_name(found->flags)); alloc_name(found->flags));
if (ret) { if (ret) {
percpu_counter_destroy(&found->total_bytes_pinned);
kfree(found); kfree(found);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment