Skip to content

Commit

Permalink
btrfs: free ulist in qgroup_shared_accounting() error path
Browse files Browse the repository at this point in the history
If tmp = ulist_alloc(GFP_NOFS) fails, we return without
freeing the previously allocated qgroups = ulist_alloc(GFP_NOFS)
and cause a memory leak.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Chris Mason <clm@fb.com>
  • Loading branch information
Eric Sandeen authored and Chris Mason committed Jun 13, 2014
1 parent b050f9f commit d737278
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/btrfs/qgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1798,8 +1798,10 @@ static int qgroup_shared_accounting(struct btrfs_trans_handle *trans,
return -ENOMEM;

tmp = ulist_alloc(GFP_NOFS);
if (!tmp)
if (!tmp) {
ulist_free(qgroups);
return -ENOMEM;
}

btrfs_get_tree_mod_seq(fs_info, &elem);
ret = btrfs_find_all_roots(trans, fs_info, oper->bytenr, elem.seq,
Expand Down

0 comments on commit d737278

Please sign in to comment.