[4.9,086/119] btrfs: fix memory leak in update_space_info failure path
diff mbox series

Message ID 20170612152602.935474259@linuxfoundation.org
State New, archived
Headers show
  • 4.9.32-stable review
Related show

Commit Message

Greg Kroah-Hartman June 12, 2017, 3:25 p.m. UTC
4.9-stable review patch.  If anyone has any objections, please let me know.


From: Jeff Mahoney <jeffm@suse.com>

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>

 fs/btrfs/extent-tree.c |    1 +
 1 file changed, 1 insertion(+)

diff mbox series

--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3984,6 +3984,7 @@  static int update_space_info(struct btrf
 				    info->space_info_kobj, "%s",
 	if (ret) {
+		percpu_counter_destroy(&found->total_bytes_pinned);
 		return ret;