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: C0P2-H0.0--20200415~8701 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=66d6448475c682099e4dd3c6b4ef6e94248c0b2e;p=linux.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 5909ae8c6731..e46e7fbe1b34 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3984,6 +3984,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; }