Skip to contentSkip to conversation

btrfs: fix memory leak in update_space_info failure path

PATCH In review [email protected] 2 participants 2 messages May 17, 2017 – May 19, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: fix memory leak in update_space_info failure path

From: Jeff Mahoney <[email protected]>

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 <[email protected]> # v3.14+
---
 fs/btrfs/extent-tree.c | 1 +
 1 file changed, 1 insertion(+)
fs/btrfs/extent-tree.c +1 -0
index be5477676cc8..2f23fd4a08f1 100644
@@ -3983,6 +3983,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;
 	}
Signature · 1 line
2.11.0